The GNU Awk User's Guide[1] is amazingly detailed, but the new AWK has bloated a lot, has 1000 features where the older one had a few dozen, and those core ones should be learnt first. (But people still like programming with it, and kept asking for features..) Hmm I don't think I use any of the new features, maybe I should...
But really, it's very simple, I can't thinking of anything that's been anything like as easy to learn, except maybe BASIC. With which AWK shares some similarities - the friendliness of it, the BEGIN and END..
[1] http://www.gnu.org/software/gawk/manual/gawk.html
[0] Or if there are too many, get names from lists of best books on a subject.
https://archive.org/download/pdfy-MgN0H1joIoDVoIC7/The_AWK_P...
You can find some discussion about it here: https://news.ycombinator.com/item?id=13451454
Delightful!
/<pattern>/ { <action> }
"For every line which matches <pattern> perform <action> " is the fundamental flow of awk programs. It's procedural but the iteration is hidden; it's almost like each stanza is a callback which gets executed when the pattern fires. I'm kinda surprised no "real language" has adopted this design for an API.But awk is actually pretty simple. Imagine everything having an implicit loop like this around it like so:
# BEGIN{ ... } would go here
for $0 in input.split('\n'):
$1, $2, ... = line.split()
# if TEST {ACTION}; pairs ...
# END { ... } would go here
so the first TEST in GP's awk would be `$1 ~ /class|module/` and the corresponding ACTION to take `{print $2}`.if TEST is omitted it's True, if ACTION is it's print the whole line.