Linux Command: gunzip
Decompress .gz files
gunzip decompresses files compressed with gzip. It is equivalent to gzip -d. gunzip replaces the .gz file with the decompressed original by default. gunzip can also decompress files created by compress (.Z files) and pack (.z files). It handles multiple files and supports keeping the original compressed file. For viewing compressed files without decompressing, use zcat (or zless, zgrep) instead.
Syntax
gunzip [OPTION]... [FILE]...Key Options
-kโ Keep compressed file-fโ Force decompression (overwrite existing)-rโ Recursively decompress-lโ List compressed file info-vโ Verbose output-cโ Write to stdout (keep original)
Examples
Decompress file
gunzip access.log.gzKeep original
gunzip -k backup.sql.gzDecompress to stdout
gunzip -c data.csv.gz | head -10Pro Tips
- Use zcat file.gz to view contents without decompressing. Or zless for paging, zgrep for searching.
- gunzip is exactly the same as gzip -d. Use whichever you remember.
- gunzip removes the .gz file by default. Use -k to keep it.
Learn more: Full gunzip reference โ