xref: /original-bsd/usr.bin/cmp/cmp.1 (revision 24b7304a)
1.\" Copyright (c) 1987, 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" %sccs.include.redist.man%
8.\"
9.\"     @(#)cmp.1	6.7 (Berkeley) 06/27/91
10.\"
11.Dd
12.Dt CMP 1
13.Os
14.Sh NAME
15.Nm cmp
16.Nd compare two files
17.Sh SYNOPSIS
18.Nm cmp
19.Op Fl l Li \&| Fl s
20.Ar file1 file2
21.Sh DESCRIPTION
22The cmp utility compares two files of any type and
23writes the results to the standard output.
24By default,
25.Nm
26is silent if the files are the same; if they differ, the byte
27and line number at which the first difference occurred is reported.
28.Pp
29Bytes and lines are numbered beginning with one.
30.Pp
31The following options are available:
32.Bl -tag -width Ds
33.It Fl l
34Print the byte number (decimal) and the differing
35byte values (octal) for each difference.
36.It Fl s
37Print nothing for differing files; return exit
38status only.
39.El
40.Pp
41If
42.Ar file1
43or
44.Ar file2
45is ``-'', the the standard input is used.
46.Pp
47The
48.Nm cmp
49utility exits with one of the following values:
50.Bl -tag -width 4n
51.It 0
52The files are identical.
53.It 1
54The files are different; this includes the case
55where one file is identical to the first part of
56the other.
57In the latter case, if the
58.Fl s
59option has
60not been specified, cmp writes to standard error
61that EOF was reached in the shorter file (before
62any differences were found).
63.It >1
64An error occurred.
65.El
66.Sh SEE ALSO
67.Xr diff 1 ,
68.Xr diff3 1
69.Sh STANDARDS
70The
71.Nm cmp
72function is expected to be POSIX 1003.2 compatible.
73