I tried this, but it always returns 1.
grep "\[10/Nov/2012" /path/to/access.log | cut -d" " -f1 | sort | uniq | wc -l
I tried this, but it always returns 1.
grep "\[10/Nov/2012" /path/to/access.log | cut -d" " -f1 | sort | uniq | wc -l
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