When working with compressed files, many standard commands cannot be used directly. For many commonly-used file and text manipulation programs, there is also a version especially designed to work directly with compressed files. These associated utilities have the letter "z" prefixed to their name. For example, we have utility programs such as zcat, zless, zdiff and zgrep.
Here is a table listing some z family commands:
Command | Description |
---|---|
$ zcat compressed-file.txt.gz | To view a compressed file |
$ zless somefile.gz or $ zmore somefile.gz | To page through a compressed file |
$ zgrep -i less somefile.gz | To search inside a compressed file |
$ zdiff file1.txt.gz file2.txt.gz | To compare two compressed files |
Note that if you run zless on an uncompressed file, it will still work and ignore the decompression stage. There are also equivalent utility programs for other compression methods besides gzip.