.TH cmp "" "" Command
.PC "Compare bytes of two files"
\fBcmp [\-ls] \fIfile1 file2\fB [\fIskip1 skip2\^\fB]\fR
.PP
.HS
.SH Options:
.IC \fB-l\fR
Print byte number and bytes at each difference
.IC \fB-s\fR
Return status (print nothing)
.Pp
If \fIfile1\fR is `-', use stdin.
If \fIskip1\fR and \fIskip2\fR are present, they are the number of bytes
to skip before comparing \fIfile1\fR and \fIfile2\fR, respectively.
.HE
The command
.B cmp
compares
two files byte by byte for equality.
.I file1
and
.I file2
name the files to compare; the file name `-' indicates the standard input.
.PP
If
.B cmp
finds two bytes that differ, it prints the number of the byte
at which the discrepancy occurs, then exits.
If it encounters EOF on one file but not on the other,
it prints the message:
.DM
	EOF on file\fIn\fP
.DE
.PP
.B cmp
recognizes the following command-line options:
.IP \fB\-l\fR 0.3i
Note each differing byte by printing the
positions and octal values of the bytes of each file.
.IP \fB\-s\fR
Print nothing, but return the exit status.
.PP
By default,
.B cmp
begins at byte 1 of each file.
The optional arguments
.I skip1
and
.I skip2
are integer values that tell
.B cmp
to skip that many bytes for the corresponding file before it begins the
comparison.
For example, the command
.DM
	cmp FOO BAR 35 40
.DE
.PP
tells
.B cmp
to skip the first 35 bytes of
.B FOO
and the first 40 bytes of
.B BAR
before it begins to compare them.
.SH "See Also"
.Xr "commands," commands
.Xr "diff," diff
.Xr "sh," sh
.Xr "zcmp" zcmp
.SH Diagnostics
.B cmd
returns zero for identical files, one for non-identical files,
and two for errors, e.g., bad command or inaccessible file.
