Skip to main content

Module 2: File Archiving & Compression

Lesson 22: zcat Command

In this lesson, you'll learn how to use the zcat command to view the contents of compressed files without uncompressing them in Linux.

zcat is a command-line utility for viewing the contents of a compressed file without literally uncompressing it. It expands a compressed file to standard output, allowing you to have a look at its contents. In addition, zcat is identical to running the gunzip -c command.

Let's discuss some examples of the zcat command.

zcat Command Syntax

zcat [OPTIONS] FILE.gz

zcat Command Options

Option Description
-f View the contents of a normal uncompressed file
-l Display properties of a compressed file (compressed size, uncompressed size, ratio, name)
-q Suppress all warnings

1. View Contents of a Compressed File

The first example shows how to view the contents of a normal file using the cat command, compress it using the gzip command, and then view the contents of the zipped file using zcat as shown.

$ cat users.list
root
tecmint
john
jane
$ gzip users.list
$ zcat users.list.gz
root
tecmint
john
jane

2. View Contents of Multiple Compressed Files

To view multiple compressed files, use the following command with filenames as shown.

$ zcat users.list.gz apps.list.gz
root
tecmint
john
jane
nginx
apache
mysql
php

3. View Contents of a Normal File

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’