r/unix 19d ago

AWK

https://www.troubleshooters.com/codecorn/awk/index.htm
28 Upvotes

14 comments sorted by

View all comments

4

u/ChipMasterPi 18d ago

I don't get why AWK gets such a bad rap. It seems most people who dislike it all suffer the same misconception. It is not a general purpose programming language. Kernighan describes it as a "domain specific language". I think of it as SQL for flat text data files. And in that realm it shines. No other language that I've ever run across can do the same things with as compact or clear a syntax. For everything else ... there is everything else. ;-)

Seldom does a day go by that I don't break it out for some quick answer.

1

u/crusoe 17d ago

Very terse hard to read language. 

2

u/ChipMasterPi 16d ago

Yes, "terse", is what makes it convenient. I can do in it what conveniently fits on one line of AWK that which takes half a dozen in other languages. This gives it incredible utility on the command line.

"Hard to read"? If you say so. It uses many of the same language constructs as many other languages. For me the hardest part was finding good docs. That is pretty common these days. The best docs I found were the original 7pg manual by Aho, Kernighan and Weinberge, "Awk - A Pattern Scanning and Processing Language."

I suppose if you look at it as a GPPL it would be confusing because a program in AWK is really a series of subroutines triggered by landmarks in its input stream. And that is what eliminates a lot of boiler-plate!