The bzcmp utility is used to invoke the cmp utility on bzip2 compressed files. All options specified are passed directly to cmp. As internally bzcmp calls cmp, We can pass the cmp command options to bzcmp.
- If only one file is specified, then the files compared are file1 and an uncompressed file1.bz2.
- If two files are specified, then they are uncompressed if necessary and fed to cmp.
bzcmp [cmp_options] file [file]
Example 1: Comparing two files as follows:
- Create the two files as follows:
Contents of file1: "GeeksForGeeks bzcmp example file1." Contents of file2: "GeeksForGeeks bzcmp example file2."
- Now compressing both the files. After that compares both the files as follows:
In the above example, bzcmp compares the
file2.bz2 and returns the first-byte position where the data differs.
Example 2: Here, we will use bzcmp with Single parameter. Edit the compressed file
file1.bz2 and replace the content from “
GeeksForGeeks bzcmp example file1.” to “
GeeksForGeeks bzcmp example file1 changed.” and execute the following command. bzcmp utility compares the file1.bz2 and file1.
Note: The output from cmp refers to temporary file name instead of a specified filename. To check the difference of contents in compressed(bz2) files you can use bzdiff command.