LinuxCommandLibrary

gzcat

Display gzipped file contents

SYNOPSIS

gzcat [OPTION]... [FILE]...

PARAMETERS

-f, --force
    Force decompression even if the file has multiple links or the corresponding uncompressed file already exists. Also suppresses prompts.

-q, --quiet
    Suppress all warning and error messages.

-S .suf, --suffix .suf
    Use the specified suffix .suf instead of the default .gz when searching for compressed files. For example, gzcat -S .zip file.

-h, --help
    Display a help message and exit.

-V, --version
    Display the version number of the gzip program and exit.

DESCRIPTION

gzcat is a Linux command-line utility that decompresses files compressed with the gzip algorithm and writes the uncompressed data to standard output. It is essentially equivalent to running gunzip -c or gzip -dc. Its primary purpose is to allow users to view the contents of a gzipped file without needing to decompress it to disk, or to pipe the decompressed data directly to another command for further processing. gzcat automatically detects and handles files with common gzip extensions like .gz, .taz, and .tgz. If no file name is provided, or if the file name is specified as a single hyphen (-), gzcat reads compressed data from standard input, making it highly versatile for use in pipelines. This command is part of the gzip package and provides a convenient, cat-like interface for compressed files.

CAVEATS

gzcat specifically handles files compressed with gzip. It will not work with other compression formats like bzip2 (.bz2), xz (.xz), or zip (.zip). For those formats, you would typically use bzcat, xzcat, or unzip -p respectively.
Since gzcat writes to standard output, any existing file with the same name as the uncompressed output will not be overwritten unless the output is redirected and explicitly handled (e.g., gzcat file.gz > file).

PIPING OUTPUT

One of the most powerful uses of gzcat is its ability to pipe the decompressed data directly to other commands. This avoids the need to create a temporary uncompressed file on disk. For example, to search for specific text within a gzipped log file, you could use:
gzcat access.log.gz | grep 'error'

READING FROM STANDARD INPUT

gzcat can read compressed data from standard input if no file argument is given or if '-' is provided as the file name. This is useful when the compressed data comes from another command in a pipeline, such as receiving a gzipped file over a network connection:
curl http://example.com/data.gz | gzcat

HISTORY

gzcat is part of the gzip project, which was developed by Jean-loup Gailly and Mark Adler in the early 1990s as a free and more efficient replacement for the proprietary compress and pack utilities commonly found on Unix systems. From its inception, the gzip suite included utilities like gunzip (for decompression) and a symbolic link or hard link named gzcat (or zcat) to provide a convenient way to view the contents of gzipped files directly to the standard output, mimicking the behavior of the standard cat command for uncompressed files.

SEE ALSO

zcat(1), gunzip(1), gzip(1), cat(1), bzcat(1), xzcat(1)

Copied to clipboard