On 09/26/03 00:25 -0400, Chris Kloiber wrote: > On Wed, 2003-09-24 at 22:13, Bill Gradwohl wrote: > > I'm trying to read a file into an array and not having much success. > > > > The following test script is self contained. > > > > #!/bin/bash > > > > # Create a test file to read > > cat >/tmp/junkfile <<-"CODE" > > line 1 > > line 2 > > line 3 > > CODE > > > > echo ===========Loop 1============== > > declare -a RULES > > i=0 > > j=4 > > > > # Read the test file line by line into the RULES array. > > cat /tmp/junkfile| while read x; do ^^^ The problem is the pipe. It starts a subprocess, which is invisible to the parent process, i.e. the outer loop. This fragment will work: echo ===========Loop 1============== declare -a RULES i=0 j=4 INFILE="/tmp/junkfile" RULES=(`cat $INFILE`) echo RULES ARRAY ${RULES[*]} John -- Shrike-list mailing list Shrike-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/shrike-list