This comprehensive Linux guide expects that you run the following commands as root user but if you decide to run the commands as a different user then ensure that the user has
sudo
access and that you precede each of the privileged commands withsudo
zcat
command decompresses the data of all the input files, and writes the result on the standard output. zcat
concatenates the data in the same way cat does.
This command can also be used to view the contents of an archive without even decompressing it. In this tutorial, we will guide you about how to use zcat
command on your linux system.
In this tutorial, we are using commands with examples. So, replace the “filename” with the name of the file and “.ext” with the extension of the file.
Displaying Contents Of A Zip File
If you want to display the contents of a zip file without decompressing it, you can run the following command
root@codesposts:~$ zcat filename.gz
Displaying Contents Of Multiple Zip Files
If you want to display the contents of multiple zip files without decompressing them, you can run the following command
root@codesposts:~$ zcat file1.gz file2.gz
Displaying Contents Of Unarchived File
If you want to display the contents of a normal/unarchived file, you can use the option -f
with the zcat
command
root@codesposts:~$ zcat -f filename.txt
Displaying Properties Of Archived File
If you want to display the properties i.e. compressed size, uncompressed size, compression ratio (0.0% if unknown), uncompressed_name, you can use the option -l
with the zcat
command
root@codesposts:~$ zcat -l filename.gz
Enabling Pagination In The Output
If you want to enable the pagination, you can use the option less/more
with the zcat
command
root@codesposts:~$ zcat filename.gz | more
root@codesposts:~$ zcat filename.gz | less
Suppressing The Warnings
To suppress all the warnings in the output, you can use the option -q
with the zcat
command
root@codesposts:~$ zcat -q filename.gz