Grep-ing gzipped files [duplicate]
I have a set of 100 log files, compressed using gzip. I need to find all lines matching a given expression. I'd use grep, but of course, that's a bit of a nightmare because I'll have to unzip all files, one by one, grep them and delete the unzipped version, because they wouldn't all fit on my sevrer if they were all unzipped.
Anyone has a little trick on how to get that done quickly?
You might have a look at zgrep
.
>$ zgrep -h
grep through gzip files
usage: zgrep [grep_options] pattern [files]
The zgrep
program exists for this specific purpose.
http://linux.about.com/library/cmd/blcmdl1_zgrep.htm
Or, if your OS doesn't come with zgrep
, something like this.
gunzip -c somefile1.gz [...] | grep 'string'