xref: /openbsd-src/usr.bin/cmp/cmp.1 (revision 28a4c76433ec4ea145fe75342fa90fa29463676d)
1*28a4c764Sjmc.\"     $OpenBSD: cmp.1,v 1.17 2014/01/25 22:08:08 jmc Exp $
2df930be7Sderaadt.\"     $NetBSD: cmp.1,v 1.4 1995/09/08 03:22:55 tls Exp $
3df930be7Sderaadt.\"
4df930be7Sderaadt.\" Copyright (c) 1987, 1990, 1993
5df930be7Sderaadt.\"	The Regents of the University of California.  All rights reserved.
6df930be7Sderaadt.\"
7df930be7Sderaadt.\" This code is derived from software contributed to Berkeley by
8df930be7Sderaadt.\" the Institute of Electrical and Electronics Engineers, Inc.
9df930be7Sderaadt.\"
10df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without
11df930be7Sderaadt.\" modification, are permitted provided that the following conditions
12df930be7Sderaadt.\" are met:
13df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright
14df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer.
15df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright
16df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer in the
17df930be7Sderaadt.\"    documentation and/or other materials provided with the distribution.
18f75387cbSmillert.\" 3. Neither the name of the University nor the names of its contributors
19df930be7Sderaadt.\"    may be used to endorse or promote products derived from this software
20df930be7Sderaadt.\"    without specific prior written permission.
21df930be7Sderaadt.\"
22df930be7Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23df930be7Sderaadt.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24df930be7Sderaadt.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25df930be7Sderaadt.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26df930be7Sderaadt.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27df930be7Sderaadt.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28df930be7Sderaadt.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29df930be7Sderaadt.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30df930be7Sderaadt.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31df930be7Sderaadt.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32df930be7Sderaadt.\" SUCH DAMAGE.
33df930be7Sderaadt.\"
34df930be7Sderaadt.\"     @(#)cmp.1	8.1 (Berkeley) 6/6/93
35df930be7Sderaadt.\"
36e76d1258Sjmc.Dd $Mdocdate: January 25 2014 $
37df930be7Sderaadt.Dt CMP 1
38df930be7Sderaadt.Os
39df930be7Sderaadt.Sh NAME
40df930be7Sderaadt.Nm cmp
41df930be7Sderaadt.Nd compare two files
42df930be7Sderaadt.Sh SYNOPSIS
43df930be7Sderaadt.Nm cmp
44df930be7Sderaadt.Op Fl l | Fl s
45df930be7Sderaadt.Ar file1 file2
46df930be7Sderaadt.Op Ar skip1 Op Ar skip2
47df930be7Sderaadt.Sh DESCRIPTION
48a06b6ec4SaaronThe
49581190f2Saaron.Nm
50a06b6ec4Saaronutility compares two files of any type and writes the results
51df930be7Sderaadtto the standard output.
52df930be7SderaadtBy default,
53df930be7Sderaadt.Nm
54df930be7Sderaadtis silent if the files are the same; if they differ, the byte
55df930be7Sderaadtand line number at which the first difference occurred is reported.
56df930be7Sderaadt.Pp
57df930be7SderaadtBytes and lines are numbered beginning with one.
58df930be7Sderaadt.Pp
598cf461a5SaaronThe options are as follows:
60f1ba3473Saaron.Bl -tag -width Ds
61df930be7Sderaadt.It Fl l
62df930be7SderaadtPrint the byte number (decimal) and the differing
63df930be7Sderaadtbyte values (octal) for each difference.
64df930be7Sderaadt.It Fl s
65*28a4c764SjmcSilent.
66df930be7SderaadtPrint nothing for differing files; return exit
67df930be7Sderaadtstatus only.
68df930be7Sderaadt.El
69df930be7Sderaadt.Pp
70df930be7SderaadtThe optional arguments
71df930be7Sderaadt.Ar skip1
72df930be7Sderaadtand
73df930be7Sderaadt.Ar skip2
74df930be7Sderaadtare the byte offsets from the beginning of
75df930be7Sderaadt.Ar file1
76df930be7Sderaadtand
77df930be7Sderaadt.Ar file2 ,
78df930be7Sderaadtrespectively, where the comparison will begin.
79a06b6ec4SaaronThe offset is decimal by default, but may be expressed as a hexadecimal
8096366692Saaronor octal value by preceding it with a leading
8196366692Saaron.Dq 0x
8296366692Saaronor
8396366692Saaron.Dq 0 .
84f1c64ac4Sjmc.Sh EXIT STATUS
85df930be7SderaadtThe
86581190f2Saaron.Nm
87df930be7Sderaadtutility exits with one of the following values:
88e76d1258Sjmc.Bl -tag -width Ds -offset indent
89df930be7Sderaadt.It 0
90df930be7SderaadtThe files are identical.
91df930be7Sderaadt.It 1
92df930be7SderaadtThe files are different; this includes the case
93df930be7Sderaadtwhere one file is identical to the first part of
94df930be7Sderaadtthe other.
95df930be7SderaadtIn the latter case, if the
96df930be7Sderaadt.Fl s
97df930be7Sderaadtoption has not been specified,
98581190f2Saaron.Nm
9996366692Saaronwrites to standard error that
10096366692Saaron.Dv EOF
10196366692Saaronwas reached in the shorter
102df930be7Sderaadtfile (before any differences were found).
103df930be7Sderaadt.It >1
104df930be7SderaadtAn error occurred.
105df930be7Sderaadt.El
106df930be7Sderaadt.Sh SEE ALSO
107df930be7Sderaadt.Xr diff 1 ,
1086272b51eSjasper.Xr diff3 1 ,
1096272b51eSjasper.Xr sdiff 1
110df930be7Sderaadt.Sh STANDARDS
111df930be7SderaadtThe
112581190f2Saaron.Nm
1137c5a075bSjmcutility is compliant with the
11499332e38Sjmc.St -p1003.1-2008
1157c5a075bSjmcspecification.
1167c5a075bSjmc.Pp
1177c5a075bSjmcThe arguments
1187c5a075bSjmc.Ar skip1
1197c5a075bSjmcand
1207c5a075bSjmc.Ar skip2
1217c5a075bSjmcare extensions to that specification.
12296366692Saaron.Sh HISTORY
12396366692SaaronA
12496366692Saaron.Nm
12596366692Saaroncommand appeared in
12696366692Saaron.At v1 .
127