Blog

Count unique IP address in Apache's access log

Aug 29, 2009
Category:Bash Linux 

This is a pretty simple but useful one liner to count the number of occurances of each unique IP is apache's access log.

sed < /var/log/httpd/access_log -e 's/ .*$//' | sort | uniq -c

It will output something like this, thats number of occurances, followed by the IP.

   4180 82.175.122.204
     98 82.28.240.185
    128 82.4.174.109
     41 83.145.79.72

Of course you will have to change the path to point to the access log that you want to count the IP's in.


Comments