Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm try this, but returns always 1.

grep "[10/Nov/2012" /path/to/access.log | cut -d" " -f1 | sort | uniq | wc -l

share|improve this question
Do you use custom log on your nginx or a default configuration ? – Gabor Vincze Nov 10 '12 at 14:06
default configuration – Diego Prates Nov 10 '12 at 16:43
up vote 2 down vote accepted
tom@webserver:/srv/tomoconnor/logfiles$ awk '/10.Nov.2012/ {print $1}' < access_log|sort|uniq |wc -l

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

share|improve this answer
Thanks Tom, it work's. I can't close this question, don't know why... – diegoprates Nov 12 '12 at 17:04
You have to tick the big green check mark next to my answer. The problem might be that you're logged in with the wrong user account. The original one has your username with 2 separate words. – Tom O'Connor Nov 12 '12 at 17:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.