BASH question
Madison Kelly
linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Sat Dec 15 11:58:40 UTC 2007
David C. Chipman wrote:
> Hi Madi,
>
> Could you do this:
>
> -- Start code ---
>
> for QRY_LINE in $(<some-mysql-cli-command>)
> do
> ROW_NUM=$(echo $QRY_LINE | awk '{ print $1 }")
> VAR1=$(echo $QRY_LINE | awk '{ print $2 }')
> VAR2=$(echo $QRY_LINE | awk '{ print $3 }')
> VAR2=$(echo $QRY_LINE | awk '{ print $4 }')
> DATE1=$(echo $QRY_LINE | awk '{ print $5 }')
> TIME=$(echo $QRY_LINE | awk '{ print $6 }')
> DATE2=$(echo $QRY_LINE | awk '{ print $7 }')
> done
>
> -- End code --
>
> I hope this works, but get rid of all the stuff above "Begin DB
> results output", if possible. If you can't you're have to grep it out
> as a part of "some-mysql-cli-command". Good luck. If I've missed
> something, let me know, I'm just a hobbyist at this stuff. Good luck!
>
> -David Chipman
Hi David,
The problem I had when ever I tried to do that was ${QRY_LINE} would
be the results split on any white space, so every word was a line,
regardless of whether it was space, tab or newline seperated... a lot of
the (real) data contained one of more words... I need something that
would populate the array by splitting on newline and then split the
containing data into variables on 'tab'.
Madi
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list