I'm parsing query results from a mysql command (with the --table parameter)
local records=`echo "${query}" | $MYSQL -u $MyUSER -h $MyHOST -p$MyPASS --table`
The query is run successfully, and I receive good data.
Then I iterate over this data:
for data in $records ;
do
test+=$data
done
The code is more extensive, but this is basically it. Bash sees every space as a separator though, and that's a problem for text fields.
So I just concatenate them. But when I feed bash this data:
*URL*
host:
test.url.com
pass:
anothertest
http://www.test.com
It concatenates it to something like:
pass:test.url.com.com
As if it's not concatenating, but overwriting. Is this maybe some carriage return problem?
printf "test=%q\n" "$test"
-- bash's %q format will print a quoted-format string, which makes it much easier to discern things like carriage returns. Try printing"$data"
each time through the loop, then printing"$test"
at the end and see how they look. – Gordon Davisson Sep 11 '12 at 1:58