You need to grep some compressed files. Do you have to uncompress them first?
Not if you have zgrep, zcat, or gzcat on your system.
zgrep is simply a grep that understands various compressed and uncompressed files (which types are understood varies from system to system).
You will commonly run into this when searching syslog messages on Linux, since the log rotation facilities leave the current log file uncompressed (so it can be in use), but gzip archival logs:
1 |
$ zgrep 'search term' /var/log/messages* |
zcat is simply a cat that understands various compressed and uncompressed files (which types are understood varies from system to system).
It might understand more formats than zgrep, and it might be installed on more systems by default.
It is also used in recovering damaged compressed files, since it will simply output everything
it possibly can, instead of erroring out as gunzip or other tools might.
gzcat is similar to zcat, the differences having to do with commercial versus free Unix variants, and backward compatibility:
1 |
$ zcat /var/log/messages.1.gz |