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\nFirst, to show you how this works, I compressed the words file on one of my Linux systems (\/usr\/share\/dict\/words) using these commands:\n$ cp \/usr\/share\/dict\/words .\n$ 7z a words.7z words\n$ bzip2 -k words\n$ gzip -k words\n$ xz -k words\n$ zip words.zip words\n\n\u00a0\nThe -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:\n$ ls -l\ntotal 9164\n-rw-r--r--. 1 shs shs 4953598 Oct 27 16:11 words\n-rw-r--r--. 1 shs shs 1230545 Oct 27 16:14 words.7z\n-rw-r--r--. 1 shs shs 1712421 Oct 27 16:11 words.bz2\n-rw-r--r--. 1 shs shs 1476067 Oct 27 16:11 words.gz\n-rw-r--r--. 1 shs shs 1230236 Oct 27 16:11 words.xz\n-rw-r--r--. 1 shs shs 1476203 Oct 28 12:42 words.zip\n\nViewing compressed-file content\nTo view the entire content of a compressed file while leaving the compressed file intact, you can use any of these commands:\n\nfor 7z:\u00a0 7z x -so words.7z\nfor bz2:\u00a0 bzcat words.bz2\nfor gz:\u00a0 zcat words.gz\nfor xz:\u00a0 xzcat words.xz\nfor zip:\u00a0 zcat words.zip\n\nFor example:\n$ bzcat words.bz2 | head -5 $ 7z x -so words.7z | head -5\n1080 1080\n10-point 10-point\n10th 10th\n11-point 11-point\n12-point 12-point\n\nYou can also pipe the output to commands like more or grep, or simply watch it scroll rapidly down your screen.\n$ 7z x -so words.7z | grep overclever\noverclever\novercleverly\novercleverness\n\nBrowsing with less\nYou can browse some types of compressed files (bz2, gz and xz) using the less command.\n$ less words.bz2 $ less words.gz $ less words.xz\n1080 1080 1080\n10-point 10-point 10-point\n10th 10th 10th\n11-point 11-point 11-point\n12-point 12-point 12-point\n... ... ...\n\nSearching for text in 7z files\nThe 7z command allows you to view files included in the archive, but searching their contents requires an extraction (-x) option. However, a command like that below leaves the compressed file intact but also extracts the contents in the process. The -so\u00a0option tells the command to write data to standard out.\n$ 7z x -so words.7z | grep clever | column\nclever cleverest cleverly overcleverly uncleverness\ncleverality clever-handed cleverness overcleverness\nclever-clever cleverish clevernesses unclever\ncleverer cleverishly overclever uncleverly\n\nThere doesn't seem to be a grep-like command for 7z files, but commands like this work very well.\nSearching for text in other types of compressed files\nTo search for specific text in compressed files, you can use commands like these:\n$ bzgrep overclever words.bz2\n$ zgrep overclever words.gz\n$ xzgrep overclever words.xz\n$ zipgrep overclever words.zip\n\nFor any of these commands, you should see these words that they pull from the compressed word files:\noverclever\novercleverly\novercleverness\n\nEditing compressed files\nUsing vi or vim, you can actually edit some compressed files (bz2, gz and xz files) to add, change, or remove content. The files will remain compressed on your disk, but you'll be able to notice the size changes.\n$ xzcat words.xz | tail -3\nZz\nzZt\nZZZ\n$ vi words.xz\n$ xzcat words.xz | tail -3\nzZt\nZZZ\nI added this line!\nWrap-Up\nGiven all the ways that you can browse and select content from compressed files, it might be a good time to exercise your "overcleverness" and see how helpful the methods described in this post might be.