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.
Thread beginning with comment 315761
To read all comments associated with this story, please click here.
Stepping stone?
by xiaokj on Tue 27th May 2008 15:08 UTC
xiaokj
Member since:
2005-06-30

Good reading.

However, what I think of awk is that it is a has-been kept alive by other packages dependant on it. I have yet to hear of new uses of awk. Instead, people use grep when scripting and efficiency is needed, or use perl when needing power.

awk ushered in perl, so should it be considered a stepping stone? I would vote yes, and I sincerely hope that, if such, we should leave it to toil away behind the scenes of history. Developers, simply put, have too many things to juggle with these days, IMHO.

RE: Stepping stone?
by whartung on Tue 27th May 2008 17:03 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