gzip Command Reference for CI Scripts
gzip shrinks a file in place; gunzip (or gzip -d) restores it.
gzip compresses one stream at a time and does not bundle multiple files (that is tar). Knowing that distinction prevents most of the errors people hit in pipelines.
Common flags/usage
- -d / --decompress: decompress (same as gunzip)
- -k / --keep: keep the input file instead of replacing it
- -c / --stdout: write to stdout and leave the input alone
- -1 .. -9: compression level, fast to best
- -l / --list: show compressed and uncompressed sizes
Example
shell
gzip -k coverage.xml # keep original, create coverage.xml.gz
gzip -dc logs.gz | grep ERROR
gzip -9 "report-${GITHUB_RUN_ID}.txt"In CI
gzip deletes the source by default, so use -k or -c when you still need the original. "unexpected end of file" means the .gz is truncated (a partial download or interrupted write). To bundle multiple files use tar -czf, not gzip alone.
Key takeaways
- gzip works on one file and removes the original unless you pass -k or -c.
- Use tar -czf to compress directories; gzip alone does not bundle files.
- "unexpected end of file" signals a truncated archive, often a failed download.
Related guides
tar Command Reference for CI Scriptstar bundles and extracts archives in CI for caches and artifacts. Reference for -c, -x, -z, -C, and the compr…
zip Command Reference for CI Scriptszip packs files into cross-platform .zip archives in CI. Reference for -r, -j, -q, and -x, plus the missing-b…
unzip Command Reference for CI Scriptsunzip extracts .zip archives in CI. Reference for -o, -d, -q, and -l, plus the interactive overwrite prompt t…
curl Command Reference for CI Scriptscurl transfers data over HTTP(S) in CI scripts. Reference for -f, -sS, -L, -o, and --retry so downloads fail…