xzcmp
Compare xz-compressed files
TLDR
Compare two specific files
SYNOPSIS
xzcmp [OPTION]... FILE1 [FILE2]
Alternative usage (for diff options):
xzcmp [DIFF_OPTION]... FILE1 [FILE2]
PARAMETERS
--help
Display a help message and exit.
--version
Display version information and exit.
[CMP_OPTION]...
Any option recognized by the 'cmp' command. These options are passed directly to 'cmp' when xzcmp decides to use 'cmp' for comparison (e.g., when called as 'xzcmp' without 'diff' options). Common 'cmp' options include -s (silent) and -l (long format).
[DIFF_OPTION]...
Any option recognized by the 'diff' command. These options are passed directly to 'diff' when xzcmp decides to use 'diff' for comparison (e.g., when 'xzcmp' is called with 'diff'-like arguments). Common 'diff' options include -q (brief), -u (unified output), and -N (treat missing files as empty).
DESCRIPTION
xzcmp is a utility for comparing files, which may be compressed using xz, lzma, gzip, or bzip2 compression formats, or even be uncompressed (raw) files. It acts as a wrapper around the standard cmp or diff commands, transparently decompressing the input files on the fly before passing them to the chosen comparison tool. This allows users to compare the contents of compressed archives directly without needing to decompress them manually beforehand. If only one file is provided, xzcmp will compare it against standard input. It's particularly useful for verifying the integrity of compressed backups or checking for differences between versions of compressed data.
CAVEATS
xzcmp requires the xzdec (or xz), gzip, and bzip2 utilities to be available in the system's PATH for decompressing files. Performance can be affected by the decompression speed and the size of the files being compared. It implicitly chooses between cmp and diff based on the options provided, which might lead to unexpected behavior if specific cmp or diff features are expected but the wrong underlying tool is chosen.
COMPARISON TOOL SELECTION
xzcmp internally chooses between the cmp and diff utilities based on the options it receives. If options typically associated with diff (e.g., -u, -q when used with two files) are given, xzcmp will likely use diff. Otherwise, it defaults to using cmp. This behavior is similar to other 'z' utilities like zcmp and bzcmp.
INPUT HANDLING
When only one FILE argument is provided, xzcmp compares the contents of that file (after decompression, if applicable) against standard input. This is useful for comparing a compressed file with data being piped from another command or a local uncompressed file without saving it to disk.
HISTORY
xzcmp is part of the xz-utils package, which provides command-line tools for LZMA and XZ compression. It effectively superseded similar tools from the older lzma_utils package. Its design principle is inherited from zcmp (from gzip) and bzcmp (from bzip2), allowing seamless comparison of compressed files by decompressing them on the fly. This avoids the need for users to manually manage temporary decompressed files. It's primarily developed and maintained as part of the broader xz-utils project.