I'm looking for caveats, tips'n'tricks etc. for awk. For example:
awk '$9=="404"{a[$7]++}END{for(i in a)print a[i],i}' access.log|less
this code, will print errors aggregated by page path.
There is a trick, to sort an array by setting WHINY_USERS to any, nonzero value, to automatically use isort function on array before printing:
WHINY_USERS=1 awk '$9=="404"{a[$7]++}END{for(i in a)print a[i],i}' access.log|less
This code will return same errors but sorted by the key name (path).
I'm looking for more tricks like this one - do you know any resource which has them listed? could you share best tricks you know? I've never found awk wiki - only same old tuts repeated over and over...
Does Awk One Liners count?
http://www.pement.org/awk/awk1line.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With