3 ms·
Not to mention, they're under-using awk. Tailing this seems completely unnecessary. The original from TFA: `tail -fq /var/log/nginx/access.log | awk '{print $
by sgarland 3y ago
Not to mention, they're under-using awk. Tailing this seems completely unnecessary.
The original from TFA:
`tail -fq /var/log/nginx/access.log | awk '{print $7}' | sort | uniq -c | sort -rn`
can be replaced with:
`awk '{ a[$7]++ } END { for (i in a) print " " a[i] " " i }' /var/log/nginx/access.log | sort -rn`
or, if you have GNU awk:
`awk '{ a[$7]++ } END { PROCINFO["sorted_in"] = "@val_num_desc"; for (i in a) print " " a[i] " " i }' /var/log/nginx/access.log`