xzcmp
Compare xz-compressed files
TLDR
Compare two specific files
SYNOPSIS
xzcmp [options] file1.xz [file2.xz]
PARAMETERS
--help
Display usage information and exit
--version
Output version information and exit
-l, --verbose
Print all differing bytes with offsets in decimal and octal
-s, --quiet, --silent
Suppress normal output; only use exit status
-i BYTES, --skip=BYTES
Skip first BYTES bytes of file1 input
-i2 BYTES, --skip2=BYTES
Skip first BYTES bytes of file2 input
-n LIMIT, --bytes=LIMIT
Compare at most LIMIT bytes
-b, --print-bytes
Print differing bytes as printable characters
-z, --zero-terminated
Use NUL as line delimiter instead of newline
DESCRIPTION
xzcmp is a utility from the XZ Utils package designed to compare the uncompressed contents of two .xz compressed files without needing to decompress them to disk first. It achieves this by piping the output of xzcat (which decompresses the files) directly into cmp for a byte-by-byte comparison. This approach is memory-efficient and ideal for large files, as it streams data without creating temporary uncompressed copies.
Usage is straightforward: specify one or two files, and xzcmp reports differences, byte offsets, and values if verbose mode is enabled. If only one file is provided, it compares its decompressed content against standard input, mimicking cmp's behavior. It's particularly useful for verifying compressed backups, checking package integrity in repositories, or ensuring consistency in compressed data archives.
Options from cmp control output verbosity, skipping bytes, limiting comparison size, and more. xzcmp exits with the same status codes as cmp: 0 for identical files, 1 for differences, and 2 for errors like invalid compression or I/O issues.
CAVEATS
Requires valid XZ streams; fails on uncompressed or corrupted files.
Does not handle concatenated/multi-file XZ archives natively.
Large files stream efficiently but may consume memory if cmp buffers excessively.
BEHAVIOR WITH STDIN
If file2 omitted, reads decompressed file1 against stdin via xzcat.
EXIT STATUS
0: files identical.
1: files differ.
2: error (e.g., invalid XZ, I/O failure).
HISTORY
Introduced in XZ Utils 4.999.3beta1 (2008) by Lasse Collin as part of LZMA/XZ tools.
Stabilized in 5.0.0 (2009); actively maintained for modern Linux distributions.


