gunzip
The gunzip command is used to decompress files created by gzip, zip, compress, or pack. It is functionally equivalent to gzip -d.
Basic Syntax
gunzip [OPTION]... [FILE]...
Common Options
| Option | Description |
|---|---|
-k, --keep | Keep (don't delete) input files during decompression. |
-r, --recursive | Operate recursively on directories. |
-c, --stdout | Write output on standard output; keep original files unchanged. |
-v, --verbose | Verbose output. |
Real-world Examples
-
Decompress a
.gzfile:gunzip archive.txt.gz(This replaces
archive.txt.gzwitharchive.txt) -
Decompress and keep the original compressed file:
gunzip -k archive.txt.gz -
View the contents of a compressed file without decompressing:
gunzip -c logfile.gz | less(Alternatively, use
zcat logfile.gz)