3 ms·
I don't write much Awk code any more, but at one time it was my favorite programming language, and not just for little one-liners. A while ago I ran across a c
by Stratoscope 7y ago
I don't write much Awk code any more, but at one time it was my favorite programming language, and not just for little one-liners.
A while ago I ran across a couple of my old Awk programs and uploaded them to GitHub. One is an implementation of Mark V. Shaney (the infamous Markov chain program), the other takes source code and prints it out in a nice "two up" landscape format on a LaserJet II, including graphical boxes to replace the ASCII dividers in comments like this:
//------------------
// Some comment here
//------------------
I wish I had a sample printout, but they are long gone.
Awk was the first language I used that had associative arrays built into the language, which made SHANEY.AWK almost trivial to write. Especially compared with implementations I saw in C and other languages of the day.
I think LJPII.AWK is a good example of how you can write a fairly substantial program in Awk and have it be (mostly) readable. (It was written for either MKS Awk or Thompson Awk, I forget which - so there are a few things in it that may not be available in a typical Awk today.)
https://github.com/geary/awk https://github.com/geary/awk
https://en.wikipedia.org/wiki/Mark_V._Shaney https://en.wikipedia.org/wiki/Mark_V._Shaney