Mailinglist Archive: opensuse-factory (883 mails)

< Previous Next >
Re: grep, cut, and all that (Re: [opensuse-factory] Status: Beta)
Am 29.05.2012 12:03, schrieb Guido Berhoerster:

Try mawk, it's an order of a magnitude faster than gawk and can be
configured as /bin/awk using update-alternatives.

Yeah, and it has incompatible syntax. The following snippet to extract
name and version from a debian control file does not work with mawk:

eval $(awk -F":[[:space:]*]" \
'/^Package:/{print "NAME=\""$2"\""};
/^Version:/{print "VERSION=\""$2"\""}' CONTROL/control)

But that's now going to be seriously offtopic here.

grep and two cuts are probably still cheaper.

If you use a modern shell such as bash or ksh93 with built-in support
for regexes neither of them should be ever needed.

Whenever I see "while read a b c; do some string processing in shell;
done < foo" code, I always wonder if a simple grep|cut would have been
more efficient. The shell is probably not as optimized for such stuff as
the specialized tools are. And often it is more readable, too.

Again seriously offtopic, so let's stop it. I know that you can do it in
$SHELL and I use that often. You are right.
Stefan Seyfried

"Dispatch war rocket Ajax to bring back his body!"
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-factory+owner@xxxxxxxxxxxx

< Previous Next >