How to count unique visitors in an nginx access.log?

Solution 1:

tom@webserver:/srv/tomoconnor/logfiles$ awk '/10.Nov.2012/ {print $1}' < access_log|sort|uniq |wc -l
169

I prefer awk to grep and cut, as you can tell it which field you want. Then just sort, uniq, and count.

You can get a count of how many hits per IP if you remove wc -l and make uniq into uniq -c