BASH question

linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Sat Dec 15 03:52:52 UTC 2007


> On Fri, Dec 14, 2007 at 06:40:23PM -0500, linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org wrote:
>> Hey all,
>>
>>   I've been banging my head against something all day that *should* be
>> easy/obvious, but obviously not to me...
>>
>> I've got a task (insane, yes, but...) to write a sample script in BASH
>> to
>> call do a mysql database call and parse the results. I've build the call
>> and can get the results showing on the screen, but I've been stumped
>> dumb
>> on how to feed the results, one line at a time, into an array.
>
> What array, and what results?  Post some sample data...

Here is a sample output:

digimer at crystal:~/projects/jc$ ./test.sh
SQL connection command: [mysql -Bs -b --disable-pager -D testdb -u user
-psecret -h localhost]
Query: [SELECT bkr_key, bkr_lnme, bkr_snme, bkr_sd_nme, ctre_dt, chng_dt
FROM BKR LIMIT 5;]
Calling: [mysql -Bs -b --disable-pager -D testdb -u user -psecret -h
localhost -e"SELECT bkr_key, bkr_lnme, bkr_snme, bkr_sd_nme, ctre_dt,
chng_dt FROM BKR LIMIT 5;"]
/- Begin DB results output -=-=-=-=-
1       foo     bar     baz     2006-12-28      2007-12-13
2       yin     yang    bork    2007-12-14 22:47:51     2007-12-14
3       red     green   grey    2007-12-14 22:48:08     2007-12-14
4       hot     cold    warm    2007-12-14 22:48:22     2007-12-14
5       wet     dry     sticky  2007-12-14 22:48:35     2007-12-14
\- End DB results output -=-=-=-=-=-

The part I would like to feed into an array is each of the five lines of
output (so that I can parse each line into individual values, but one step
at a time).

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