Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Reading compressed files using 'zcat' command  (Read 2150 times)

0 Members and 1 Guest are viewing this topic.

rohitj

  • Guest
Reading compressed files using 'zcat' command
« on: November 30, 2013, 11:56:34 am »
Reading compressed files using 'zcat' command


If we have thousands of text files and we have compressed these text files for saving the disk space and we want to read it without decompressing it, we can make use of zcat command.

In this example, show the contents of a text file called resume.txt.gz that has been compressed using gzip.

Open the Terminal and then type the following commands.

Display resume.txt.gz on screen.

zcat resume.txt.gz

You can also list a compressed file with zless command or zmore command as shown below.

$ zcat filename.gz | more
$ zcat filename.gz | less

(or)

$ zless filename.gz
$ zmore filename.gz


When you are not sure whether a file is compressed or not, you can still view the file without worrying about it’s compression status as shown below.

zcat -f file.txt

Enjoy  ;)