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
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 integrityOptions
| Flag | What it does |
|---|---|
| -k / --keep | Keep the .xz file |
| -c / --stdout | Write to stdout |
| -t / --test | Test integrity only |
| -T0 / --threads=0 | Use multiple cores where the stream allows |
| -f / --force | Overwrite 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.