LinuxCommandLibrary

bzcmp

Compare bzip2 compressed files

SYNOPSIS

bzcmp [cmp_options] file1 [file2]

PARAMETERS

-b, --print-bytes
    Print differing bytes as printable characters

-i BYTES, --skip=BYTES
    Skip first BYTES bytes of input from both files

-l, --verbose
    Output in verbose format showing byte numbers and values

-n BYTES, --bytes=BYTES
    Compare at most BYTES bytes

-s, --quiet, --silent
    Do not output normal diagnostic information

-h, --help
    Display usage information and exit

-V, --version
    Output version information and exit

DESCRIPTION

bzcmp is a utility from the bzip2 compression suite that compares bzip2-compressed (.bz2) files without requiring manual decompression. It acts as a front-end to the cmp(1) command, using bzcat(1) to decompress the inputs on the fly via pipes and then invoking cmp on the resulting streams.

This approach saves disk space and time, making it ideal for checking integrity of compressed backups, verifying identical archives, or spotting differences in compressed data. Like cmp, it reports the byte offset and differing values of the first mismatch, or states if files are identical. If only one file is given, the second is read from stdin.

bzcmp supports standard cmp options for customized output, such as suppressing messages or limiting comparison scope. It is a hard link to bzdiff(1) in some implementations, inheriting similar behavior. Primarily for single-stream bzip2 files, it may handle concatenated streams but errors on invalid compression.

CAVEATS

Assumes inputs are valid bzip2 files; use cmp(1) for uncompressed.
Decompression uses memory proportional to file size.
May fail on corrupted streams or multi-part archives.

EXIT STATUS

0: files identical; 1: files differ; 2: error (e.g., read failure)

EXAMPLE

bzcmp data1.bz2 data2.bz2
Reports first differing byte or "identical".

HISTORY

Introduced in bzip2 1.0 (1996) by Julian Seward as part of core utilities. Stable across Linux distros since bzip2 adoption in late 1990s.

SEE ALSO

cmp(1), bzdiff(1), bzcat(1), bzip2(1), zcmp(1)

Copied to clipboard