Open In App

Working with zcat, zmore and zless Command in Linux

Last Updated : 10 Oct, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Compression means to keep files together in an archive and to reduce the size of files. Gzip a.k.a. Gunzip is a command in Linux which is used to compress and decompress the files. So in case, you compressed a very large file with gzip and you just want to see what are the contents of the file. As in this case decompression of the file is going to take a lot of time, so in order to save time and view files without decompressing them “zcat” command is used. 

 

Working with zcat command

1. To display contents of a Gzipped file. 

$zcat filename.gz

To-display-contents-of-a-Gzipped-file

This will print all the contents of the compressed file. 

Note: In this case the, name of file is filename.gz. 

2. To display contents of multiple compressed files. 

$zcat file1.gz file2.gz

To-display-content-of-multiple-compressed-files

It display contents of multiple files together. 

Note: In this case the, name of file is file1.gz and file2.gz. 

3. To read compressed data even from a terminal and even it is compressed or not. 

$zcat -f filename.gz

To-read-compressed-data-even-from-a-terminal

This displays the content of the file even if the content is binary or is in an encrypted form. 

Note: In this case the, name of file is filename.gz. 

4. To paginate the output. 

$zless filename.gz

To-paginate-the-output

$zmore filename.gz

To-paginate-the-output

These are the commands used for paginating the output. 

Note: In this case the, name of file is filename.gz. 

5. To get the properties of the compressed file.  

$zcat -l filename.gz

to-get-the-properties-of-the-compressed-file

This will display the properties of files like compressed and uncompressed ratio and uncompressed name etc. 

Note: In this case the, name of file is filename.gz. 

6. To suppress all warnings.  

$zcat -q filename.gz

to-suppress-all-warnings-in-zcat

This will suppress all the warnings that will occur in between the execution of the command.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads