Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I grep server access logs for unique IPs and a specific page?

I want to grep my server logs to collect all of the unique IP Addresses, and also to see all of the requests for a specific page. What is the best way to do this?

like image 866
damon Avatar asked Jul 10 '09 15:07

damon


1 Answers

Assuming this is a standard Apache log, and assuming you are on Unix, I usually do

awk '{print $1}' access.log|sort -u

The awk filters out all IP addresses, the sort then removes duplicates.

To find out all accesses to a URL, I do

grep URL access.log

Of course, you will have to replace "URL" with the specific one you search for.

like image 182
Martin v. Löwis Avatar answered Sep 29 '22 11:09

Martin v. Löwis