Using AWK with tail -f to Watch Referers

Sometimes I like to see which web sites are referring traffic to me in real time. Here’s the command line script I use to do it. It uses awk to parse the incoming log file for real time display in a terminal:

tail -f mylogfile-access.log | awk -F\" '($4 !~ /mysitename|^-?$/){print $4,$2}' | uniq

I use the mysitename and ^-?$ expresssions to strip out self-generated referrals and empty referral fields.

Comments are closed.