Find unique IP addresses that hit your webserver
cat /var/log/httpd/access_ log | awk '{print $1}' | sort | uniq | wc -l |
- first we use the cat command to list all the entries in the apache log file.
- we send that to awk which extracts the first item on each line which should be the IP
- then we sort all the IPs, this is needed for the uniq command
- we apply the uniq filtering command to remove duplicate IPs
- then we count the number of lines left using word count command wc
# filter out unique requests for a given day, in this case Jan 1st 2012
cat
/var/log/httpd/access_
log |
grep
"\[01/Jan/2012"
|
awk
'{print $1}'
|
sort
|
uniq
|
wc
-l
# getting a list of unique referrers
cat
/var/log/httpd/access_
log |
awk
'{print $11};'
|
awk
-F /
'{print $3}'
|
sort
|
uniq
No comments:
Post a Comment