2 ms·
Hmm, the vital thing to say is that awk is a series of PATTERN { ACTION } statements, where { ACTION } is optional and defaults to { print } Side note; I
by emmelaich 7y ago
Hmm, the vital thing to say is that awk is a series of
PATTERN { ACTION }
statements, where { ACTION } is optional and defaults to { print }
Side note; I almost always use Perl or Ruby with the -n or -p flags instead of awk. I don't need to have three or four syntaxes to remember when I can use just one.
- vram22 7y ago>where { ACTION } is optional and defaults to { print } There's more to that: Either PATTERN or { ACTION } is optional (but not both). If no PATTERN is given, the default means "match every line" (and so do the given ACTION for every line). The ACTION could be anything (even an explicit print, whether or not PATTERN is given), summing up some column, filtering more on substring(...), assigning values to variables, comparing variables and doing actions based on them (awk's if statement), calling a built-in or user-defined function, etc.