Skip to content
Latchkey

bunzip2: Decompress .bz2 Files in CI

bunzip2 decompresses .bz2 files and is equivalent to bzip2 -d, restoring the original by stripping the .bz2 suffix.

bunzip2 is the read side of bzip2. In CI you use -k to keep the archive and -c to stream it into tar or a grep.

What it does

bunzip2 reads a .bz2 file, decompresses it, writes the original name without the suffix, and deletes the compressed file unless -k is set. It is identical in behavior to bzip2 -d.

Common usage

Terminal
bunzip2 backup.tar.bz2          # -> backup.tar
bunzip2 -k data.bz2            # keep data.bz2
bunzip2 -c logs.bz2 | grep WARN
bunzip2 -t archive.bz2         # integrity test

Options

FlagWhat it does
-k / --keepKeep the .bz2 file
-c / --stdoutWrite to stdout
-t / --testTest integrity only
-f / --forceOverwrite existing output
-v / --verboseReport the compression ratio

Common errors in CI

"bunzip2: <file> is not a bzip2 file" means the input is not .bz2, often a mislabeled gzip or xz. "bunzip2: Compressed file ends unexpectedly" is a truncated file; re-download. "bunzip2: Can't open input file <name>: No such file or directory" is a bad path.

Related guides

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