Hi folks,
I am going nuts trying to read the output of a mysql select statement
into an array. I have consulted bashfaq and other sources and tried
various approaches, but every jump was somewhat short, it seems.
This is what I tried (bash is 3.2.xx, I tried on MacOS X and Debian Lenny):
while read -r; do messag[i++]=$REPLY; done < <(mysql select
statement) # this is from BashFAQ Nr. 5 - is this possible with
bash 3.2.x at all?
this got me complains about unexpected "<" and such
$(mysql select command) | while read line; do messag+=($line);
done # this basically works, but counting up the array index does not
I also tried
... do messag[i++]=($line)
# -bash: messag[i++]: cannot assign
list to array member (????)
... do messag[i]=$line && i=$(($i+1))
... do messag[$i]=$line && i=$(($i+1))
It never results in every line of the mysql output becoming an array
element.
I really tried finding out myself, but I am stuck, so please can someone
point me to what I do wrong?
Thanks in advance,
Dirk