Name
cmp
Synopsis
cmp [options]file file2[skip1[skip2]]
Compares file1 with
file2. Use standard input if
file1 or file2
is - . To begin the comparison from byte offsets other than at the
beginning of the files, use the optional arguments
skip1 and
skip2, which specify the byte offsets from
the beginning of each file. By default, the value is decimal. To use
hexadecimal or octal values, precede them with a leading
0x or 0, respectively. See also
comm and diff. The exit codes
are as follows:
-
0 Files are identical.
-
1 Files are different.
-
2 Files are inaccessible.
Options
-
-c,--print-chars Print differing bytes as characters.
-
-iN,--ignore-initial=N Ignore differences in the first
Nbytes of input.-
-l For each difference, print the byte number in decimal and the differing bytes in octal.
-
-s Work silently; print nothing, but return exit codes.
-
-v,--version Output version info.
Example
Print a message if two files are the same (exit code is 0):
$ cmp -s old new && echo 'no changes'Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access