awk and access.log

I keep forgetting about the single quotes in this incantation. Writing it down won’t improve my memory, but I’ll know where to look it up.

To see a field (e.g. referers) from Apache’s combined access.log:

# cat /var/log/apache/logname | awk '($11 !~ /sitename|\-/) {print $11}'

This strips out references from the site itself, plus entries with a – in the field. Mostly useful when testing anti-referer-spam stuff.

Stalk me on social media