Linked by Thom Holwerda on Tue 27th May 2008 13:08 UTC, submitted by Ward D
General Development AWK is one of the most common UNIX tools to process text-based data in either files or datastreams. Written by Alfred Aho, Peter Weinberger, and Brian Kernighan, AWK "extensively uses the string datatype, associative arrays (that is, arrays indexed by key strings), and regular expressions." ComputerWorld interviewed Alfred Aho.
Permalink for comment 315789
To read all comments associated with this story, please click here.
RE: Stepping stone?
by whartung on Tue 27th May 2008 17:03 UTC in reply to "Stepping stone?"
whartung
Member since:
2005-07-06

I dunno if it's a stepping stone or not. I think today most folks step up to Perl simply because more folks know Perl.

But I discovered AWK early, and it's still my hammer of choice, dropping in to Perl only for true edge cases that AWK simply doesn't work well.

I find it easier to work with than Perl, and for most of my work, the extra power and utility of Perl simply isn't necessary. I typically just need to do basic processing, and AWK is perfect for that.

It's not unheard of for me to pipe a couple of small AWK programs together with other shell utilities. Again, Perl could probably handle the entire task, but a combination of my familiarity with the classic Unix utilities, Perl's complexity, and AWKs simplicity all conspire to make me use the shell and AWK before I even think of using Perl. Typically, if I need Perl, I need to crack open a book/website. AWK and the shell I have, effectively, memorized.

I strongly suggest AWK to anyone. It's clever pattern -> action paradigm is quite simple, and really powerful.

And, as Aho said, it's just great for throw away programs. I have /tmp/x.awk almost permanently living on my disk, constantly being rewritten.

One of my common idioms is to edit a data file (in vi, of course), then :!vi /tmp/x.awk, create/edit a script, then ZZ back to my file, 1G!Gawk -f /tmp/x.awk to run the script on the buffer. If I don't like the changes, hit u to undo and edit the awk script again. Rinse and repeat.

It's a great tool.

Reply Parent Bookmark Score: 3