3 ms·
Awk did have this reputation of hard-to-read one liners, but it was also always possible to write readable code in it much as you would do in any language. My
by Stratoscope 8y ago
Awk did have this reputation of hard-to-read one liners, but it was also always possible to write readable code in it much as you would do in any language.
My favorite bit of Awk code that I ever wrote was this print formatting program for the HP LaserJet II:
https://github.com/geary/awk/blob/master/LJPII.AWK https://github.com/geary/awk/blob/master/LJPII.AWK
It printed source code in a "2-up" format, with two pages printed side by side in landscape mode. It looked for the kind of separators that I and many people were fond of back in those days (the source code is a good example) and converted those to graphic boxes. And it tried to be smart about things like breaking pages before a comment box, not after.
I wish I still have a sample printout handy. For 300 lines of what I thought was fairly cleanly written Awk code, it made some nicely formatted printouts.
- oblio 8y agoThat's very clean looking code and I think it would be considered so regardless of the language it was written in, IMHO. Nice! :)