xref: /openbsd-src/usr.bin/cmp/cmp.1 (revision 28a4c76433ec4ea145fe75342fa90fa29463676d)
1.\"     $OpenBSD: cmp.1,v 1.17 2014/01/25 22:08:08 jmc Exp $
2.\"     $NetBSD: cmp.1,v 1.4 1995/09/08 03:22:55 tls Exp $
3.\"
4.\" Copyright (c) 1987, 1990, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" This code is derived from software contributed to Berkeley by
8.\" the Institute of Electrical and Electronics Engineers, Inc.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)cmp.1	8.1 (Berkeley) 6/6/93
35.\"
36.Dd $Mdocdate: January 25 2014 $
37.Dt CMP 1
38.Os
39.Sh NAME
40.Nm cmp
41.Nd compare two files
42.Sh SYNOPSIS
43.Nm cmp
44.Op Fl l | Fl s
45.Ar file1 file2
46.Op Ar skip1 Op Ar skip2
47.Sh DESCRIPTION
48The
49.Nm
50utility compares two files of any type and writes the results
51to the standard output.
52By default,
53.Nm
54is silent if the files are the same; if they differ, the byte
55and line number at which the first difference occurred is reported.
56.Pp
57Bytes and lines are numbered beginning with one.
58.Pp
59The options are as follows:
60.Bl -tag -width Ds
61.It Fl l
62Print the byte number (decimal) and the differing
63byte values (octal) for each difference.
64.It Fl s
65Silent.
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 a hexadecimal
80or octal value by preceding it with a leading
81.Dq 0x
82or
83.Dq 0 .
84.Sh EXIT STATUS
85The
86.Nm
87utility exits with one of the following values:
88.Bl -tag -width Ds -offset indent
89.It 0
90The files are identical.
91.It 1
92The files are different; this includes the case
93where one file is identical to the first part of
94the other.
95In the latter case, if the
96.Fl s
97option has not been specified,
98.Nm
99writes to standard error that
100.Dv EOF
101was reached in the shorter
102file (before any differences were found).
103.It >1
104An error occurred.
105.El
106.Sh SEE ALSO
107.Xr diff 1 ,
108.Xr diff3 1 ,
109.Xr sdiff 1
110.Sh STANDARDS
111The
112.Nm
113utility is compliant with the
114.St -p1003.1-2008
115specification.
116.Pp
117The arguments
118.Ar skip1
119and
120.Ar skip2
121are extensions to that specification.
122.Sh HISTORY
123A
124.Nm
125command appeared in
126.At v1 .
127