Skip to content
Latchkey

gunzip: Decompress .gz Files in Pipelines

gunzip decompresses .gz files and is exactly equivalent to gzip -d, restoring the original name by stripping the .gz suffix.

gunzip is what you reach for when a cache or artifact arrives as .gz. In CI you usually want -k to keep the archive and -c to pipe straight into tar.

What it does

gunzip reads a .gz file, decompresses it, and writes the original by removing the .gz suffix, deleting the compressed file unless you keep it with -k. It is the same binary behavior as gzip -d.

Common usage

Terminal
gunzip cache.tar.gz             # -> cache.tar, removes .gz
gunzip -k backup.sql.gz         # keep backup.sql.gz
gunzip -c data.gz | grep ERROR  # stream without writing a file
gunzip -t archive.gz            # test integrity only

Options

FlagWhat it does
-k / --keepKeep the .gz file after decompressing
-c / --stdoutWrite output to stdout
-t / --testTest the compressed file integrity
-f / --forceOverwrite an existing output file
-l / --listList compressed and uncompressed sizes

Common errors in CI

"gzip: stdin: not in gzip format" means the input is not gzip; a common cause is a file renamed to .gz that is actually xz or a plain tar. "gzip: <file>: decompression OK, trailing garbage ignored" is usually a concatenated or truncated stream. "unexpected end of file" means the download was truncated; re-fetch the artifact.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →