diffutils: Invoking cmp
12 Invoking ‘cmp’
*****************
The ‘cmp’ command compares two files, and if they differ, tells the
first byte and line number where they differ or reports that one file is
a prefix of the other. Bytes and lines are numbered starting with 1.
The arguments of ‘cmp’ are as follows:
cmp OPTIONS... FROM-FILE [TO-FILE [FROM-SKIP [TO-SKIP]]]
The file name ‘-’ is always the standard input. ‘cmp’ also uses the
standard input if one file name is omitted. The FROM-SKIP and TO-SKIP
operands specify how many bytes to ignore at the start of each file;
they are equivalent to the ‘--ignore-initial=FROM-SKIP:TO-SKIP’ option.
By default, ‘cmp’ outputs nothing if the two files have the same
contents. If the two files have bytes that differ, ‘cmp’ reports the
location of the first difference to standard output:
FROM-FILE TO-FILE differ: char BYTE-NUMBER, line LINE-NUMBER
If one file is a prefix of the other, ‘cmp’ reports the shorter file's
name to standard error, followed by a blank and extra information about
the shorter file:
cmp: EOF on SHORTER-FILE EXTRA-INFO
The message formats can differ outside the POSIX locale. POSIX
allows but does not require the EOF diagnostic's file name to be
followed by a blank and additional information.
An exit status of 0 means no differences were found, 1 means some
differences were found, and 2 means trouble.
Menu