4 ms·
The post doesn't mention it, but the best source for learning awk is _The Awk Programming Language_ (http://cm.bell-labs.com/cm/cs/awkbook/ http://cm.bell-labs.
by silentbicycle 16y ago
The post doesn't mention it, but the best source for learning awk is _The Awk Programming Language_ (http://cm.bell-labs.com/cm/cs/awkbook/ http://cm.bell-labs.com/cm/cs/awkbook/) by Aho, Weinberger, and Kernighan. It's short and to the point, has a good tutorial and reference, and it's even co-written by Brian Kernighan. It's that good. There's also a collection at resources at http://awk.info/ http://awk.info/ .
Awk's pattern-structured rules are very powerful, and learning to use them well (rather than writing if statements, etc.) is a big part of using awk idiomatically.
Also, note which awk you're using - awk may actually be nawk ("new awk", the awk that book covers) or GNU awk, which, in typical FSF fashion, has grafted on a whole bunch of extra functionality. (Although the networking stuff is cool.) Things will probably make more sense if you start with nawk, and then explore the sprawling extensions of gawk.
- koenigdavidmj 16y agoActually, all three authors of that book (not just BWK) are the original authors of awk(1).
- silentbicycle 16y agoCorrect, didn't think that sounded ambiguous.
- Nick_C 16y agoFYI, the bell-labs link seems to be broken.
- silentbicycle 16y agoThe ISBN is 020107981X. For some reason, new copies are really expensive ($80+), but used copies are typically only $15ish.