LinuxCommandLibrary

zcmp

Compare compressed files

TLDR

Invoke cmp on two files compressed via gzip

$ zcmp [path/to/file1.gz] [path/to/file2.gz]
copy

Compare a file to its gzipped version (assuming .gz exists already)
$ zcmp [path/to/file]
copy

SYNOPSIS

zcmp [ options ] file1 file2

PARAMETERS

file1
    The first file to compare. May be compressed.

file2
    The second file to compare. May be compressed.

-v, --verbose
    Verbosely print the command line arguments as they are parsed.

-q, --quiet, --silent
    Suppress all normal output.

-l, --long
    Output byte number and differing byte value for each difference.

-s, --silent
    Output nothing, but return an exit status of 1 if differences are found.

-i, --ignore-initial=N
    Ignore the first N bytes of both files.

-n length, --bytes=length
    Compare at most length bytes.

-Z, --compress
    Force gzip mode. Only applicable if invoked as zcmp. For bzcmp and xzcmp the default decompression tool is forced.

DESCRIPTION

The zcmp command is used to compare compressed files. It functions similarly to the standard cmp command, but it operates directly on files compressed with gzip, bzip2 or xz. zcmp first uncompresses the input files in memory before comparing them, so it avoids the need to manually decompress files before performing a comparison. It is particularly useful for quickly checking if two large, compressed files are identical without writing the decompressed content to disk. If one of the files is not compressed, zcmp will uncompress the compressed file and compare it to the uncompressed file.

EXIT STATUS

The zcmp command returns an exit status of 0 if the files are identical, 1 if they differ, and 2 or greater if an error occurred.

SEE ALSO

cmp(1), gzip(1), bzip2(1), xz(1), zdiff(1), zless(1), zmore(1)

Copied to clipboard