Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
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 '13 at 15:07
    
@Andy: Yes. I am just not sure about the colon after the year. –  choroba Jan 25 '13 at 15:09
    
Just omit the last two character in your search string :) –  Shadok Jan 25 '13 at 15:09
    
@choroba I'm not sure why but after looking at one log the format is definitely like that –  Andy Jan 25 '13 at 15:10
    
@Andy: OK. I just was not sure. –  choroba Jan 25 '13 at 15:11
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.