zgrep and zcat ussage

finding content in uncompressed files (extension, gzip).

In a directory, there are many .gz files , how do we search for a particulary word in those files.
one solution is to unzip the .gz file and use the grep command.

Here are the steps

gunzip filename.gz
grep "searchword" file

The other and better solution is using zgrep command in unix

zgrep "search word" filename.gz

grep comand work on text files, zgrep works on compressed logs.

To view the compressed files, use zcat command in linux or unix

No comments:

Post a Comment

Note: only a member of this blog may post a comment.