bzdiff
Compare compressed files line by line
SYNOPSIS
bzdiff [diff_options] PATH1 PATH2
PARAMETERS
diff_options
Any valid option supported by the underlying diff(1) command. These options are passed directly to diff.
PATH1
The first file or directory to compare. If it's a file ending with .bz2, it will be decompressed automatically. If it's a directory, bzdiff compares files within it.
PATH2
The second file or directory to compare. Similar decompression logic applies as for PATH1.
DESCRIPTION
bzdiff is a utility that allows users to compare the contents of two bzip2 compressed files, or a compressed file against an uncompressed file or directory. It functions as a convenient wrapper around the standard diff(1) command. When invoked, bzdiff transparently decompresses the specified .bz2 files into temporary locations on the filesystem. Once uncompressed, these temporary files are then passed as arguments to diff for the actual comparison. All options and arguments provided to bzdiff are faithfully passed through to diff. This transparency is its core strength, enabling users to quickly view differences between versions of compressed data, such as archived logs, backups, or source code, without the manual overhead of decompressing and then deleting temporary files. It significantly streamlines workflows that involve frequently comparing compressed data.
CAVEATS
Temporary Files: bzdiff creates temporary uncompressed files during operation, which might consume significant disk space for very large compressed inputs.
Performance: Decompression adds overhead, potentially slowing down comparisons for extremely large files compared to comparing uncompressed files directly.
Error Handling: If a specified file is not a valid bzip2 archive, bzdiff will typically report a decompression error (from bzip2) before diff can proceed.
Dependency: Requires the bzip2 compression suite to be installed and its executables (e.g., bzip2, bunzip2) to be available in the system's PATH.
USAGE EXAMPLES
To compare two compressed files:
bzdiff file1.log.bz2 file2.log.bz2
To compare a compressed file with an uncompressed version, showing side-by-side differences:
bzdiff -y old_config.bz2 new_config
To ignore whitespace changes during comparison:
bzdiff -w archive_v1.tar.bz2 archive_v2.tar.bz2
HISTORY
bzdiff is typically distributed as part of the bzip2 compression suite, originally developed by Julian Seward. Its primary purpose is to provide a convenient wrapper for diff that handles bzip2 compressed files transparently, similar to how zdiff works for gzip files. It emerged as a practical tool for system administrators and developers working with compressed data, eliminating the need for manual decompression steps prior to comparison.