The cmp utility compares two files of any type and writes the results to the standard output. By default, cmp is silent if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported.
In the output, bytes and lines are numbered beginning with one; however, range inputs are zero-based; see below for details. A filename of - represents standard input.
The following options are available:
Output the differing bytes as characters, rather than as octal numbers. Non-printable characters will be shown in form.
-i NUM, --ignore-initial=NUM
Ignore NUM initial characters from each file. This is a synonym for specifying NUM NUM as the two RANGE arguments.
Print the byte number (decimal) and the differing byte values (octal) for each difference.
-s, --quiet, --silent
Print nothing for differing files; return exit status only.
The two optional arguments RANGE1 and RANGE2 represent byte ranges to compare within the files. Each range can be expressed in several ways:
Skip M bytes at the beginning of the input, then compare a maximum of N bytes.
Skip M bytes at the beginning of the input, and read between bytes M and N, which are both zero-based.
The cmp utility exits with one of the following values:
The files or byte ranges are identical.
The files or byte ranges are different; this includes the case where one file or range is identical to the first part of the other. In the latter case, if -s has not been specified, cmp writes to standard output that EOF was reached in the shorter file.