Re: How to do an array?



On 2007-04-08, Dave Kelly wrote:

I am going to ask this here. Part belongs in this users group and
part in another. I have a html file that consists of several hundred
lines such as the group below. To store the data on the server, am I
correct to say an array is created and for this example the array
has a name of 'describe[]'?

<div style="text-align: center;"><h2>Personal Data</h2></div>
<p>Your Name:&nbsp;&nbsp;<input type=text name=describe[] size="40%"
maxlength=256>
Tel:&nbsp;&nbsp;<input type=text name=describe[] size="30%" maxlength=16>
Date of Report:&nbsp;&nbsp;<input type=text name=describe[] size="10%"
maxlength=16></p>
<p>Your Address:&nbsp;&nbsp;<input type=text name=describe[] size="60%"
maxlength=1024>
E-Mail:&nbsp;&nbsp;<input type=text name=describe[] size="30%"
maxlength=1024></p>
</body>

I need to fill the [] with a number. I had wanted to write a shell script
to do that. I have googled for 2 days and have yet to discover how
to increment a numerical variable in 'sed'.

Use awk, not sed, e.g.:

awk 'BEGIN { n = 1 }
{ while ( sub(/[[][]]/,"[" n "]" ) ) ++n ; print }
' FILENAME > NEWFILE

Can someone help me or more importantly, tell me where the tutorial is
that will
answer these question.


--
Chris F.A. Johnson <http://cfaj.freeshell.org>
========= Do not reply to the From: address; use Reply-To: ========
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
.



Relevant Pages

  • Re: Finding the nearest match without reusing results
    ... comparing an array with a value generates an array of Trues and ... Any diff with wrong State or with used Store is implicitly zeroed out. ... Each must be larger than the absolute value of the maximum Sales ... go.....it just needs to return the closest match. ...
    (microsoft.public.excel.programming)
  • Re: read keyboard input and storing in an array?
    ... > I'm trying to store user input in an array, ... You have the beginnings of that logic already since your prompt tells the ... 201st value since the array only has room for 200 values. ... This will force you to store the int values as Integer ('Integer' ...
    (comp.lang.java.help)
  • Re: Challenge: reading ascii data
    ... to store all the data before producing any output. ... would be bad practice in terms of memory consumption to use a standard ... So I use hashes to create a two-level "sparse array", ... Well the original problem definition was: ...
    (comp.lang.fortran)
  • Re: attempting an actual game...
    ... >>> and inflexible by the absurd decision to use a bit array for square ... as then one has 8 bits in which to store a color and a few flags ... Using a 2D int (or, ... > Change direction and you may eventually complete a game. ...
    (comp.games.development.programming.misc)
  • Re: Sparse arrays
    ... >access array element, set it, sit for a bit, and read it back ... ONLY operations are STORE and RETRIEVE with no structure to the ... If you can tolerate a bit of inefficiency ... They live in sorted lists. ...
    (comp.lang.fortran)