0

I need to get output of any lines in all Apache access log files that have 25/Jan/2013:00:25 in them. My hosting company are being unhelpful in my investigation to track down what domain is allowing a spammer to send out mail

I wanted to just search a "global" log file for all access through Apache regardless of the domain but have been told there isn't such a thing and I must search all log files for all domains separately

The path wildcard(s) is/are /var/www/vhosts//statistics/logs/access_log and /var/www/vhosts//statistics/logs/access_log.processed

Is there a grep command I can run to get all matching lines from all files?

1 Answer 1

4

Sure, grep can work with multiple files. Just run

grep '25/Jan/2013:00:25' /var/www/vhosts/*/statistics/logs/access_log{,.processed}

Your shell should do the expansion without problem, if you want more details about shell expansion have a look here:
http://www.gnu.org/software/bash/manual/bashref.html#Shell-Expansions

BTW, double check your time string.

7
  • Do you mean it seems wrong because there aren't any seconds on the time? I left seconds out because I want to return lines between 00:25:00 and 00:25:59, would this work like that?
    – Andy
    Jan 25, 2013 at 15:07
  • @Andy: Yes. I am just not sure about the colon after the year.
    – choroba
    Jan 25, 2013 at 15:09
  • Just omit the last two character in your search string :)
    – Shadok
    Jan 25, 2013 at 15:09
  • @choroba I'm not sure why but after looking at one log the format is definitely like that
    – Andy
    Jan 25, 2013 at 15:10
  • @Andy: OK. I just was not sure.
    – choroba
    Jan 25, 2013 at 15:11

You must log in to answer this question.

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