Skip to content

Instantly share code, notes, and snippets.

@dexit
Forked from loisaidasam/gist:2774350
Created April 26, 2016 18:27
Show Gist options
  • Save dexit/61717f1e593c65c6e7a8c2b3b0182ded to your computer and use it in GitHub Desktop.
Save dexit/61717f1e593c65c6e7a8c2b3b0182ded 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