[Fwd: Re: [SLUG] arrays]

Martin Webb martin at webb.lcbroadband.co.uk
Wed Nov 30 21:03:45 GMT 2005


Stephen O'Neill wrote:

> Martin Webb wrote:
>
>> I'm using:
>> arr=( `cat "$filename"`)     #  Loads contents from data file 
>
> Ok, this does work:
>
> ====================
> filename="test2.txt"
> declare -a arr
> i=0
>
> while read line
> do
>   arr[$i]=${line}
>   let "i++"
> done < "$filename"
>
> echo ${arr[0]}
> echo ${arr[1]}
> ====================
>
> Steve O 

You're right, Steve, this does work, and the whole script now works 
according to plan.
I know you are busy with the Library Display, so only reply (if you feel 
like it) when you have a moment at some time in the future.
You ask if my script is "young".  What does that mean?  It's about three 
days old, and hasn't yet had a birthday - I think I started it on Sunday.
What is sh/perl?  You ask if I like it.  I know that perl is a 
programming language.  I've used several in my time, including C at an 
elementary level, Basic in several forms, and I've written search 
programs in compiler (PSH X, NOP, etc.), so I probably would like it.
Can I suggest a future meeting include some workshop time, run by one or 
two of us who are good at scripting, so non-experts like me can be 
improved and have chance to ask questions.
Another meeting workshop might include vim.  Al's really gd at that.
Woja think?
Thanks for all the help!
Martin





More information about the Scarborough mailing list