LinuxCommandLibrary

gunzip

Decompress gzipped files

TLDR

Extract a file from an archive, replacing the original file if it exists

$ gunzip [archive.tar.gz]
copy

Extract a file to a target destination
$ gunzip --stdout [archive.tar.gz] > [archive.tar]
copy

Extract a file and keep the archive file
$ gunzip --keep [archive.tar.gz]
copy

List the contents of a compressed file
$ gunzip --list [file.txt.gz]
copy

Decompress an archive from stdin
$ cat [path/to/archive.gz] | gunzip
copy

SYNOPSIS

gunzip [options] [file(s)]

PARAMETERS

-c, --stdout, --to-stdout
    Write output on standard output; keep original files.

-d, --decompress, --uncompress
    Decompress.

-f, --force
    Force overwrite of output file and compress although having multiple links.

-h, --help
    Display help and exit.

-k, --keep
    Keep (don't delete) input files during compression or decompression.

-l, --list
    List compressed file contents.

-n, --no-name
    When compressing, do not save the original file name and timestamp.

-N, --name
    When compressing, save original file name and timestamp.

-q, --quiet
    Suppress all warnings.

-r, --recursive
    Operate recursively on directories.

-S .suf, --suffix .suf
    Use suffix .suf on compressed files.

-t, --test
    Test compressed file integrity.

-v, --verbose
    Verbose mode.

-V, --version
    Display version number and exit.

DESCRIPTION

Gunzip is a compression utility used to compress or decompress files. It's commonly used to extract files that have been compressed using gzip. By default, gunzip decompresses files, replacing the compressed file with the decompressed one, while keeping the same file name, but removing the .gz suffix.

The tool can operate on single files or multiple files specified as arguments on the command line. When gunzip compresses, it typically creates a file with the '.gz' extension. It uses the Lempel-Ziv coding (LZ77) algorithm for compression. Gunzip is part of the GNU project and available on most Unix-like systems.

CAVEATS

If a compressed file has multiple links, gunzip refuses to decompress it unless the -f or --force option is given.

EXIT STATUS

Normally, the exit status is 0. If an error occurs, the exit status is 1. If a warning occurs, the exit status is 2. The manual page contains a fuller list of potential errors and exit codes.

HISTORY

Gunzip was developed as part of the GNU project to provide a free alternative to the compress utility that was subject to patent restrictions. The gzip format is now widely used for data compression due to its efficiency and open nature.

SEE ALSO

gzip(1), zcat(1), bzip2(1), xz(1)

Copied to clipboard