MLUG: [MLUG] perl, awk, sed, etc.
[MLUG] perl, awk, sed, etc.
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
On Tue, 4 Dec 2007, Michael wrote:

I very frequently call perl from the bash script to do various little things, almost always regexp search/replace because that is what I know.

Nothing wrong with that. Perl for short things and especially good for regexp stuff. Of course awk and sed can sometimes be good for small things too. :)

On SOLARIS, awk and sed can both be limited or buggy. The GNU versions are clearly superior. Example: awk can only count fields (NF) up to something like 256, which is not enough! sed also fails without warning with long lines -- this bug is rather famous because it causes some installation scripts to fail on SOLARIS.


All I really know how to do with sed is search/replace, I just do it in perl instead. I feel much more confident that it will work and the code will be portable to any system that has perl running.

I do use gawk a lot (but not awk, though I believe these are identical on a GNU/Linux system). Mostly stuff like this:

gawk -F'\t' '$4>3 {print $2" "$5}' file.in > file.out

Mike

_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members