0

I have a bunch of apache access log files and I want to know which IP addresses visited my /contacts folder. How can I collect them from all log files with shell command?

2

1 Answer 1

2

Just use simple grep and awk command to filter records and show IPs. For common log format you can use something like this:

cat /path/to/apache/accesslog/dir/* |grep "/contacts" |awk '{ print $1 }' |sort -u

Or there is better way - setup some central logging and analyzing tool (like ELK stack) and use it for global analyzing across time and data.

2
  • 1
    UUOC and UUOG ;) awk '/contacts/ {print $1} /path/to/apache/accesslogdir/*
    – user9517
    Mar 9, 2016 at 21:47
  • maybe too complicated but I cannot remember higher syntax of awk that this to "print field number x in stdin and print it out" so this works for me. Mar 10, 2016 at 16:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .