6

I tried this, but it always returns 1.

grep "\[10/Nov/2012" /path/to/access.log | cut -d" " -f1 | sort | uniq | wc -l
chrki
  • 236
  • 1
  • 11
Diego Prates
  • 63
  • 1
  • 1
  • 3

1 Answers1

11
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

Tom O'Connor
  • 27,440
  • 10
  • 72
  • 148
  • 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