/usr/bin/cmp [-l | -s] file1 file2 [skip1] [skip2]
cmp compares two files file1 and file2. cmp writes no output if the files are the same. By default, if the files differ, the byte and line number at which the first difference occurred are written to standard output. Bytes and lines are numbered beginning with 1.
skip1 and skip2 are initial byte offsets into file1 and file2 respectively, and can be either octal or decimal. A leading 0 denotes octal.
If either file1 or files2 is -, cmp uses standard input for that operand.
The following options are supported:
Write the decimal byte number and the differing bytes (in octal) for each difference.
Write nothing for differing files. Return non-zero exit status only.
The following operands are supported:
A path name of the first file to be compared. If file1 is −, the standard input is used.
A path name of the second file to be compared. If file2 is −, the standard input is used.
If both file1 and file2 refer to standard input or refer to the same FIFO special, block special or character special file, an error results.
See largefile(5) for the description of the behavior of cmp when encountering files greater than or equal to 2 Gbyte (231 bytes).
The following example does a byte for byte comparison of file1 and file2:
example% cmp file1 file2 0 1024
It skips the first 1024 bytes in file2 before starting the comparison.
See environ(5) for descriptions of the following environment variables that affect the execution of cmp: LANG, LC_ALL , LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following error values are returned:
The files are identical.
The files are different. This includes the case where one file is identical to the first part of the other.
An error occurred.
See attributes(5) for descriptions of the following attributes: