bzcmp
Compare bzip2 compressed files
SYNOPSIS
bzcmp [OPTION]... FILE1 FILE2 [OFFSET1 [OFFSET2]]
PARAMETERS
-l, --verbose
Print the byte number and differing byte values (in octal) for all differences found.
-s, --quiet, --silent
Do not print any output; only return an exit status indicating whether files differ.
--help
Display a help message and exit.
--version
Output version information and exit.
FILE1
The path to the first bzip2 compressed file to be compared.
FILE2
The path to the second bzip2 compressed file to be compared.
OFFSET1
Optional byte offset into FILE1 to begin comparison.
OFFSET2
Optional byte offset into FILE2 to begin comparison, if OFFSET1 is also specified.
DESCRIPTION
bzcmp is a shell script utility designed to compare the contents of two bzip2 compressed files without requiring prior manual decompression. It acts as a convenient wrapper around the standard cmp command. When invoked, bzcmp decompresses the specified .bz2 files on-the-fly and pipes their content to cmp, which then performs a byte-by-byte comparison. This allows users to quickly ascertain if two compressed archives are identical or to pinpoint the first byte where they differ, mirroring the behavior of cmp on uncompressed files. It is an essential tool for managing and verifying data stored in bzip2 format.
CAVEATS
Caveats and Limitations:
Requires both the bzip2 compressor/decompressor and the cmp utility to be installed and accessible in the system's PATH.
It exclusively handles files compressed with bzip2 (typically ending with .bz2). For gzip files, use gzcmp.
The comparison is byte-by-byte, providing details on the first differing byte, unlike diff which compares line-by-line.
Performance may be slightly impacted by the on-the-fly decompression, though often faster than manual decompression.
EXIT STATUS
bzcmp typically returns the exit status of the underlying cmp command:
0: The files are identical.
1: The files differ.
2: An error occurred (e.g., file not found, permission denied, invalid arguments).
HISTORY
bzcmp emerged as part of the bzip2 utilities suite, developed to offer a streamlined approach for interacting with bzip2 compressed files without the need for manual decompression. Its design mirrors that of gzcmp, which serves a similar purpose for gzip files, simplifying operations for users who frequently work with compressed data. The command's utility is directly linked to the widespread adoption and continuous evolution of the bzip2 compression algorithm in Unix-like operating environments.