LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

zcat

View gzip-compressed file contents

TLDR

View contents of a gzipped file
$ zcat [file.gz]
copy
View contents of multiple gzipped files
$ zcat [file1.gz] [file2.gz]
copy
Pipe output to another command
$ zcat [file.gz] | grep "[pattern]"
copy
Display with line numbers
$ zcat [file.gz] | nl
copy
Page through a gzipped file
$ zcat [file.gz] | less
copy
Concatenate and decompress multiple files into one output
$ zcat [file1.gz] [file2.gz] > [combined.txt]
copy

SYNOPSIS

zcat [options] [file ...]

DESCRIPTION

zcat decompresses gzip-compressed files and writes the uncompressed data to standard output, similar to cat for regular files. It is equivalent to gunzip -c or gzip -dc.zcat can decompress files created by gzip, zip, compress, or pack. It recognizes compressed files by their magic number, not just the .gz extension, allowing decompression of files with non-standard names.When reading from stdin, zcat will pass through data that is not in a recognized compressed format unchanged (acting like cat).

PARAMETERS

-f, --force

Force decompression even if file has multiple links or the suffix does not match.
-q, --quiet
Suppress all warning messages.
-v, --verbose
Display filename and compression ratio for each file.
-h, --help
Display help message and exit.
-V, --version
Display version information and exit.

CAVEATS

zcat only outputs to stdout; it cannot decompress files in place. For decompressing to files, use gunzip or gzip -d. On some systems (e.g., macOS), zcat may be installed as gzcat to avoid conflicts with the compress utility's zcat. Unlike gzip/gunzip, zcat does not support flags like -t (test), -l (list), -k (keep), or -r (recursive) since it only reads and decompresses to stdout.

HISTORY

zcat is part of the gzip package, originally written by Jean-loup Gailly and Mark Adler. gzip was first released in 1992 as a free replacement for the Unix compress utility, which was encumbered by patents on the LZW algorithm. The gzip package became a GNU project and is now a standard utility on Unix-like systems.

SEE ALSO

gzip(1), gunzip(1), cat(1), zless(1), zgrep(1), bzcat(1), xzcat(1)

Copied to clipboard
Kai