Skip to content
Latchkey

bzcat: Stream bzip2 Files to stdout

bzcat decompresses a .bz2 file to stdout without touching disk, equivalent to bunzip2 -c, so you can inspect or pipe .bz2 data directly.

bzcat is the .bz2 sibling of zcat. Use it to grep compressed logs or feed a .bz2 stream into tar with no scratch file.

What it does

bzcat reads one or more .bz2 files and writes their decompressed contents to stdout, the same as bunzip2 -c. It writes nothing to disk, so it is meant for inspection and piping in a pipeline.

Common usage

Terminal
bzcat archive.log.bz2 | grep WARN
bzcat data.tar.bz2 | tar -x          # extract without a temp file
bzcat dump.sql.bz2 | mysql mydb      # restore straight from .bz2
bzcat a.bz2 b.bz2 > combined.txt

Options

ItemWhat it does
bzcat <file.bz2>Decompress to stdout (like bunzip2 -c)
multiple filesConcatenate all decompressed outputs
-s / --smallUse less memory at some speed cost

In CI

bzcat lets a restore or extract read straight from a .bz2 without an intermediate file, saving disk on constrained runners. It comes with the bzip2 package, so no separate install is needed once bzip2 is present.

Common errors in CI

"bzcat: (stdin) is not a bzip2 file" means the input is not .bz2; use zcat, xzcat, or zstdcat for the actual format. "bzcat: Compressed file ends unexpectedly" is a truncated file. "command not found" means the bzip2 package is not installed.

Related guides

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