Does there exist a magical shell piping which would allow easily to grep through bunch of .gz log files without needing to extract them somewhere?

.gz files are Apache logs, result of log rotation. I'd like to quickly check how often certain URIs are accessed in the past.

link|improve this question

56% accept rate
feedback

5 Answers

up vote 10 down vote accepted

The zgrep program is available for Linux (and perhaps some Unix too). This will decompress the files and then grep through them.

link|improve this answer
2  
+1. See also: zcat, zegrep, zmore, zless... – SmallClanger May 11 '11 at 12:15
feedback

You can just use zgrep to grep through compressed files.

If you need to use a specific grep, you can set the GREP environment variable:

export GREP=/bin/egrep
link|improve this answer
feedback

Should you for some reason lack zgrep you can do the same thing with gunzip and a pipe:

gunzip -c <filename.gz> | grep <whatever you want to grep for>
link|improve this answer
feedback

How about zgrep? Seems to be installed on Mac OS and Ubuntu 11.04.

link|improve this answer
feedback

I usually use: zcat filename.gz | less

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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