BASH question

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Mon Dec 17 15:25:14 UTC 2007


On Fri, Dec 14, 2007 at 06:40:23PM -0500, linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org wrote:
>   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.
> 
>   Any tips/suggestions/helpful whacks up-side the head are much appreciated!

Well you are using the wrong language for a start.  As soon as you hit
the concept of 'parsing the output' then shell scripts should no longer
be considered.  It's time to move to python or perl or php or something
else with sensible support for text parsing.  Shell scripts are good at
dealing with files and running programs and the occational small bit of
parsing to control those things.  To actually process text output and do
stuff with it you move onto a different type of language.  bash will be
very inefficient at it.

--
Len Sorensen
--
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