Re: BASH Guru needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 24, 2003 at 09:13:00PM -0500, Bill Gradwohl wrote:
> I'm trying to read a file into an array and not having much success.

Sorry, I don't have an answer for you, I just found your problem
interesting. I've learnt some more bash!

I first thought that it might have something to do with a new process
being forked (like when you use ()'s) because of the | in loop 1. But
echo $$ sprinkled around shows this not to be the case.

However, this variant of your loop also works like Loop 2:

echo ===========Loop 3==============
declare -a RULEZ
i=0
j=4
                                                                                                                                    
# Read the test file line by line into the RULEZ array.
while read x
do
   RULEZ[i++]="$x"
   # Show what RULEZ contains
   echo j=$j i=$i RULEZ has ${#RULEZ[*]} elements. ${RULEZ[*]}
done < /tmp/junkfile
echo j=$j i=$i RULEZ has ${#RULEZ[*]} elements. ${RULEZ[*]}


-- 
Norman Gaywood, Systems Administrator
School of Mathematics, Statistics and Computer Science
University of New England, Armidale, NSW 2351, Australia

norm@xxxxxxxxxxxxxxxxx            Phone: +61 (0)2 6773 2412
http://turing.une.edu.au/~norm    Fax:   +61 (0)2 6773 3312

Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html


-- 
Shrike-list mailing list
Shrike-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/shrike-list

[Index of Archives]     [Fedora Users]     [Centos Users]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat Phoebe Beta]     [Yosemite Forum]     [Fedora Discussion]     [Gimp]     [Stuff]     [Yosemite News]

  Powered by Linux