CMP(1) BSD Reference Manual CMP(1)
c
\bcm
\bmp
\bp - compare two files
S
\bSY
\bYN
\bNO
\bOP
\bPS
\bSI
\bIS
\bS
c
\bcm
\bmp
\bp [-
\b-l
\bl | -
\b-s
\bs] _
\bf_
\bi_
\bl_
\be_
\b1 _
\bf_
\bi_
\bl_
\be_
\b2 [_
\bs_
\bk_
\bi_
\bp_
\b1 [_
\bs_
\bk_
\bi_
\bp_
\b2]]
D
\bDE
\bES
\bSC
\bCR
\bRI
\bIP
\bPT
\bTI
\bIO
\bON
\bN
The cmp utility compares two files of any type and writes the results to
the standard output. By default, c
\bcm
\bmp
\bp is silent if the files are the
same; if they differ, the byte and line number at which the first differ-
ence occurred is reported.
Bytes and lines are numbered beginning with one.
The following options are available:
-
\b-l
\bl Print the byte number (decimal) and the differing byte values (oc-
tal) for each difference.
-
\b-s
\bs Print nothing for differing files; return exit status only.
The optional arguments _
\bs_
\bk_
\bi_
\bp_
\b1 and _
\bs_
\bk_
\bi_
\bp_
\b2 are the byte offsets from the be-
ginning of _
\bf_
\bi_
\bl_
\be_
\b1 and _
\bf_
\bi_
\bl_
\be_
\b2, respectively, where the comparison will be-
gin. The offset is decimal by default, but may be expressed as an hex-
adecimal or octal value by preceding it with a leading ``0x'' or ``0''.
The c
\bcm
\bmp
\bp utility exits with one of the following values:
0 The files are identical.
1 The files are different; this includes the case where one file is
identical to the first part of the other. In the latter case, if
the -
\b-s
\bs option has not been specified, c
\bcm
\bmp
\bp writes to standard output
that EOF was reached in the shorter file (before any differences
S
\bSE
\bEE
\bE A
\bAL
\bLS
\bSO
\bO
S
\bST
\bTA
\bAN
\bND
\bDA
\bAR
\bRD
\bDS
\bS
The c
\bcm
\bmp
\bp utility is expected to be IEEE Std1003.2 (``POSIX'') compatible.