Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display the top X visitors by IP address from a single or all nginx access log files
# Display the top 20 visitors by IP address from a single log file
awk '{print $2}' /var/log/nginx/access.log | sort | uniq -c | sort -nr | head -20
# Display the top 40 visitors by IP address from all rotated gzipped log files
zcat /var/log/nginx/access.log* | awk '{print $2}' | sort | uniq -c | sort -nr | head -40
# Find IP adrdresses for all users that created a custoter account for Magento
zcat /var/log/nginx/access.log* | awk -v OFS='\t' '/\/customer\/account\/createpost?/ {print $2, $21}' | sort | uniq -c | sort -nr | head -40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment