Problem with array element assignment

2007-04-15 Thread homac
Hello,


i experienced a problem with array element assignment.

The following script should read a text file and assign every line
beginning with the symbol '?' to the array U.


The script:

i=0
cat test.txt | while read s l ; do
case $s in
( '?' )  U[i]=$l ; ((i++)) ;;
esac
done
echo ${#U[*]}


Content of the input file 'test.txt':

? fragezeichen1
? fragezeichen2
? fragezeichen3
A alpha1
A alpha2
B beta1
? fragezeichen4
A alpha3


Output of the script (number of elements in array U):

0



Greetings
 Homac


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: Problem with array element assignment

2007-04-15 Thread Paul Jarc
homac <[EMAIL PROTECTED]> wrote:
> cat test.txt | while read s l ; do

Read entry E4 in the bash FAQ:
http://tiswww.case.edu/php/chet/bash/FAQ


paul


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash