BASH question
Lennart Sorensen
lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Mon Dec 17 15:28:59 UTC 2007
On Sat, Dec 15, 2007 at 07:00:41AM -0500, Madison Kelly wrote:
> It's for a client, and I already have a perl and ruby version of the
> same script. He wants the three versions for comparison (he likes bash
> scripts, knows perl and is interested in ruby). So I just need to figure
> out how to make it work.
If you need a 3rd, use python or even awk (although I wouldn't want to
write it). bash is just wrong for text processing no matter how much
someone likes bash scripts. The result won't be a bash script, it will
be a bash script calling sed or awk scripts to do the actual work,
making for something rather unreadable and inefficient.
> I figured I would need to learn sed and awk, but I can't begin that
> until I can feed each row of the DB query into an array... Hence my
> question here. :)
Why an array? awk deals very well with taking things apart into tokens.
Also remember that in bash whenever you don't want something turned into
tokens, you put "s around it so echo "$foo" gives the contents of $foo
as is, while echo $foo will tokenize it and spit them out seperately.
It's quite a nightmare to deal with text processing in a shell.
--
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