$linuxjunkies
>

gunzip(1)

Decompress files compressed with gzip, restoring them to their original form.

UbuntuDebianFedoraArch

Synopsis

gunzip [OPTION]... [FILE]...

Description

gunzip decompresses files that were compressed using the gzip compression program. It replaces each compressed file with an uncompressed version, removing the .gz suffix by default. gunzip can also decompress files with other gzip-compatible suffixes like .z or .tgz.

If no file is specified, gunzip reads from standard input and writes to standard output, making it useful in pipelines. Multiple files can be decompressed in a single command.

Common options

FlagWhat it does
-cWrite output to standard output; don't modify original files
-dDecompress (same as gunzip, included for gzip compatibility)
-fForce decompression, overwriting existing files without prompting
-kKeep input files; don't remove .gz file after decompression
-lList compression ratio and original size for each compressed file
-nDon't restore original filename and timestamp from gzip header
-qSuppress warning messages
-rRecursively decompress all .gz files in directories
-tTest integrity of compressed file without decompressing
-vVerbose; show name and percentage reduction for each file

Examples

Decompress file.txt.gz to file.txt, removing the .gz file

gunzip file.txt.gz

Extract a tar.gz archive by piping decompressed output to tar

gunzip -c file.tar.gz | tar x

Decompress file.gz but keep the original compressed file

gunzip -k file.gz

Decompress all .gz files in current directory with verbose output showing compression ratios

gunzip -v *.gz

Test the integrity of file.gz without actually decompressing it

gunzip -t file.gz

List compression information (size reduction, original size) for all .gz files

gunzip -l *.gz

Read gzip-compressed data from stdin and decompress to stdout

zcat file.gz | gunzip

Recursively decompress all .gz files in archive/ directory and subdirectories

gunzip -rf archive/

Related commands