ANSI, make exit codes consistent
[unix-history] / usr / src / usr.bin / cmp / cmp.1
CommitLineData
b5dc1377
CL
1.\" Copyright (c) 1987, 1990 The Regents of the University of California.
2.\" All rights reserved.
d0e4a4f2 3.\"
b5dc1377 4.\" %sccs.include.redist.man%
85ae1ebc 5.\"
5325ced3 6.\" @(#)cmp.1 6.4 (Berkeley) %G%
b5dc1377
CL
7.\"
8.Dd
9.Dt CMP 1
10.Os BSD 4.4
11.Sh NAME
12.Nm cmp
13.Nd compare two files
14.Sh SYNOPSIS
15.Nm cmp
5325ced3 16.Op Fl l Li \&| Fl s
b5dc1377
CL
17.Ar file1 file2
18.Sh DESCRIPTION
5325ced3
CL
19The cmp utility compares two files of any type and
20writes the results to the standard output.
b5dc1377 21Under default options,
5325ced3
CL
22.Nm
23is silent
24if the files are the same; if they
25differ, the byte and line
26number at which the first difference occurred is reported.
b5dc1377
CL
27Bytes and
28lines are numbered beginning with one.
29.Pp
30The following options are available:
5325ced3 31.Tw Ds
b5dc1377
CL
32.Tp Fl l
33Print the byte number (decimal) and the differing
5325ced3 34byte values (octal) for each difference, respectively.
b5dc1377
CL
35.Tp Fl s
36Print nothing for differing files; return exit
37status only.
38.Tp
39.Pp
b5dc1377
CL
40The following operands are available:
41.Tw file1
42.Tp Ar file1
43A pathname of the first file to be compared.
44If
45.Ar file1
46is
5325ced3 47.Sq Fl ,
b5dc1377
CL
48the standard input is used.
49.Tp Ar file2
50A pathname of the second file to be compared.
51.Tp
52.Pp
b5dc1377
CL
53The
54.Nm cmp
55utility exits with one of the following values:
5325ced3 56.Tw Ds
b5dc1377
CL
57.Tp 0
58The files are identical.
59.Tp 1
60The files are different; this includes the case
61where one file is identical to the first part of
62the other.
5325ced3
CL
63In the latter case, if the
64.Fl s
65option has
b5dc1377
CL
66not been specified, cmp writes to standard error
67that EOF was reached in the shorter file (before
68any differences were found).
69.Tp >1
70An error occurred.
71.Tp
72.Sh SEE ALSO
5325ced3
CL
73.Xr diff 1 ,
74.Xr diff3 1
b5dc1377
CL
75.Sh STANDARDS
76The
77.Nm cmp
78function is expected to be POSIX 1003.2 compatible.
5325ced3 79This manual page is derived from the POSIX 1003.2 manual page.