Sunday, 8 July 2012

Counting Ips in an access log

So,  If you need to look through an apache access log and count how many IP addresses there are this is how:
root@sertechs [~]# cd /usr/local/apache/logs/

root@sertechs [~]#  cat access_log | awk '{print$1}' | sort | uniq -c | sort -nr | less

So this command will write out your access file to screen, use awk to print the first column, sort it, get the unique values, then sort it with a count, and print to "less".

Very useful to see if your being scraped!

No comments:

Post a Comment