xref: /netbsd-src/usr.bin/cmp/cmp.1 (revision 5e4c038a45edbc7d63b7c2daa76e29f88b64a4e3)
1.\"	$NetBSD: cmp.1,v 1.8 2002/02/08 01:36:20 ross Exp $
2.\"
3.\" Copyright (c) 1987, 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" the Institute of Electrical and Electronics Engineers, Inc.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"	This product includes software developed by the University of
20.\"	California, Berkeley and its contributors.
21.\" 4. Neither the name of the University nor the names of its contributors
22.\"    may be used to endorse or promote products derived from this software
23.\"    without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35.\" SUCH DAMAGE.
36.\"
37.\"     @(#)cmp.1	8.1 (Berkeley) 6/6/93
38.\"
39.Dd June 6, 1993
40.Dt CMP 1
41.Os
42.Sh NAME
43.Nm cmp
44.Nd compare two files
45.Sh SYNOPSIS
46.Nm
47.Op Fl l | Fl s
48.Ar file1 file2
49.Op Ar skip1 Op Ar skip2
50.Sh DESCRIPTION
51The cmp utility compares two files of any type and writes the results
52to the standard output.
53By default,
54.Nm
55is silent if the files are the same; if they differ, the byte
56and line number at which the first difference occurred is reported.
57.Pp
58Bytes and lines are numbered beginning with one.
59.Pp
60The following options are available:
61.Bl -tag -width flag
62.It Fl l
63Print the byte number (decimal) and the differing
64byte values (octal) for each difference.
65.It Fl s
66Print nothing for differing files; return exit
67status only.
68.El
69.Pp
70The optional arguments
71.Ar skip1
72and
73.Ar skip2
74are the byte offsets from the beginning of
75.Ar file1
76and
77.Ar file2 ,
78respectively, where the comparison will begin.
79The offset is decimal by default, but may be expressed as an hexadecimal
80or octal value by preceding it with a leading ``0x'' or ``0''.
81.Pp
82The
83.Nm
84utility exits with one of the following values:
85.Bl -tag -width 4n
86.It 0
87The files are identical.
88.It 1
89The files are different; this includes the case
90where one file is identical to the first part of
91the other.
92In the latter case, if the
93.Fl s
94option has not been specified,
95.Nm
96writes to standard output that EOF was reached in the shorter
97file (before any differences were found).
98.It \*[Gt]1
99An error occurred.
100.El
101.Sh SEE ALSO
102.Xr diff 1 ,
103.Xr diff3 1
104.Sh STANDARDS
105The
106.Nm
107utility is expected to be
108.St -p1003.2
109compatible.
110