[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Reading mysql data stream into array
From: |
Dirk |
Subject: |
Reading mysql data stream into array |
Date: |
Fri, 06 May 2011 18:07:37 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 |
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
- Reading mysql data stream into array,
Dirk <=