Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tuantranf/92520a990c9503b7718d9b7e281a1838 to your computer and use it in GitHub Desktop.
Save tuantranf/92520a990c9503b7718d9b7e281a1838 to your computer and use it in GitHub Desktop.
One liner for counting unique IP addresses from nginx logs
# One liner for counting unique IP addresses from nginx logs
# Feel free to comment with better ideas - I'm sure it's not the best way of doing this (I'm no awk ninja!)
#
# Sample output:
#
# $ cat example.com.access.log | awk -F " " '{a[$1]++ } END { for (b in a) { print b, "\t", a[b] } }'
# 66.65.145.220 49
# 92.63.28.68 126
cat example.com.access.log | awk -F " " '{a[$1]++ } END { for (b in a) { print b, "\t", a[b] } }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment