Compare two files, and if they differ, tells the first byte and line number where they differ.
You can use the &qt;cmp&qt;&qt; command to show the offsets and line numbers where two files differ. &qt;cmp&qt;&qt; can also show all the characters that differ between the two files, side by side.
SYNTAX
cmp options… FromFile [ToFile]
OPTIONS
Multiple single letter options (unless they take an argument)
can be combined into a single command line word:
so &qt;-cl&qt;&qt; is equivalent to &qt;-c -l&qt;&qt;.
&qt;-c&qt;&qt;
Print the differing characters. Display control characters as a
&qt;^&qt;&qt; followed by a letter of the alphabet and precede characters
that have the high bit set with &qt;M-&qt;&qt; (which stands for "meta").
&qt;–ignore-initial=BYTES&qt;&qt;
Ignore any differences in the the first BYTES bytes of the input
files. Treat files with fewer than BYTES bytes as if they are
empty.
&qt;-l&qt;&qt;
Print the (decimal) offsets and (octal) values of all differing
bytes.
&qt;–print-chars&qt;&qt;
Print the differing characters. Display control characters as a
&qt;^&qt;&qt; followed by a letter of the alphabet and precede characters
that have the high bit set with &qt;M-&qt;&qt; (which stands for "meta").
&qt;–quiet&qt;&qt;
&qt;-s&qt;&qt;
&qt;–silent&qt;&qt;
Do not print anything; only return an exit status indicating
whether the files differ.
&qt;–verbose&qt;&qt;
Print the (decimal) offsets and (octal) values of all differing
bytes.
&qt;-v&qt;&qt;
&qt;–version&qt;&qt;
Output the version number of &qt;cmp&qt;&qt;.
The file name &qt;-&qt;&qt; is always the standard input. &qt;cmp&qt;&qt; also uses the
standard input if one file name is omitted.
An exit status of 0 means no differences were found, 1 means some
differences were found, and 2 means trouble.
Example
$ cmp tnsnames.ora tnsnames.old
Notes
&qt;cmp&qt;&qt; reports the differences between two files character by character, instead of line by line. As a result, it is more useful than &qt;diff&qt;&qt; for comparing binary files. For text files, &qt;cmp&qt;&qt; is useful mainly when you want to know only whether two files are identical.
For files that are identical, &qt;cmp&qt;&qt; produces no output. When the files differ, by default, &qt;cmp&qt;&qt; outputs the byte offset and line number where the first difference occurs. You can use the &qt;-s&qt;&qt; option to suppress that information, so that &qt;cmp&qt;&qt; produces no output and reports whether the files differ using only its exit status.
Unlike &qt;diff&qt;&qt;, &qt;cmp&qt;&qt; cannot compare directories; it can only compare two files.