Grepping through .gz log files
Solution 1
The zgrep program is available for Linux (and perhaps some Unix too). This will decompress the files and then grep through them.
Solution 2
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>
Solution 3
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
Solution 4
I usually use:
zcat filename.gz | less
Solution 5
How about zgrep? Seems to be installed on Mac OS and Ubuntu 11.04.
Related videos on Youtube

Mikko Ohtamaa
Building Trading Strategy, a decentralised algorithmic trading protocol
Updated on September 18, 2022Comments
-
Mikko Ohtamaa 3 months
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.
-
SmallClanger over 11 years+1. See also:
zcat
,zegrep
,zmore
,zless
...