Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
1  
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

1 Answer 1

up vote 2 down vote accepted
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

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

 
discard

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.