I'm trying to calculate the number of unique visits on a URL from my apache logs.
Here is what I have so far:
grep -o 'THIS_IS_MY_URL' other_vhosts_access.log | wc -l
This is working, but I'm not filtering on unique IPs yet. Do you have any idea?
Thanks !
Those log files are most of the time in the following format:
<IP> - - <TIMESTAMP> <METHOD> <URL> ....
So instead of just using grep, we'll need some more:
-o
from grep so we're getting the whole line where the matching URL is foundcut -d' ' -f1
to get only a list of IP addresses [docs]uniq
to filter it to only unique values [docs]wc -l
grep 'SEARCH ME' file.log | cut -d' ' -f1 | uniq | wc -l