Skip to content

Searching through compressed files on Linux

There are quite a few ways to search through compressed text files on Linux systems without having to uncompress them first. Depending on the format of the files, you can choose to view entire files, extract specific text, navigate through file contents searching for content of interest, and sometimes even edit content. I

First, to show you how this works, I compressed the words file on one of my Linux systems (/usr/share/dict/words) using these commands:

$ cp /usr/share/dict/words .
$ 7z a words.7z words
$ bzip2 -k words
$ gzip -k words
$ xz -k words
$ zip words
How to use the grep command on Linux

The -k options used with the bzip2, gzip, and xz commands kept these commands from removing the original file, which they would by default. The resultant files then looked like this:

To read this article in full, please click here

Source:: Network World – Linux