Skip to content
Latchkey

unxz: Decompress .xz Files in Pipelines

unxz decompresses .xz files and is equivalent to xz -d, restoring the original by stripping the .xz suffix.

unxz is the read side of xz. Many release tarballs ship as .tar.xz, so unxz (or tar -J) shows up wherever you consume them.

What it does

unxz reads a .xz file, decompresses the LZMA2 stream, writes the original name without the suffix, and removes the compressed file unless -k is set. It is the same binary as xz invoked in decompress mode.

Common usage

Terminal
unxz linux.tar.xz              # -> linux.tar
unxz -k firmware.bin.xz       # keep the .xz
unxz -c data.xz | tar -x      # stream into tar
unxz -t release.tar.xz        # test integrity

Options

FlagWhat it does
-k / --keepKeep the .xz file
-c / --stdoutWrite to stdout
-t / --testTest integrity only
-T0 / --threads=0Use multiple cores where the stream allows
-f / --forceOverwrite existing output

Common errors in CI

"xz: (stdin): File format not recognized" means the file is not xz; a common cause is a .xz name on a gzip or lzma stream. "xz: <file>: Unexpected end of input" is a truncated download. Multi-threaded decompression only works on streams written in multiple blocks (xz -T with a block size); single-block .xz decompresses single-threaded regardless of -T0.

Related guides

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