Merge commit '008b34be09d7b9c3e7a18d3ce9ef8b5c4f4ff8b8'
[unleashed.git] / share / man / man1 / cmp.1
blob098bcc4e86a3cf1f181c4007e2682ecbf666ba1a
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
45 .\" Copyright (c) 2006, Sun Microsystems, Inc.  All Rights Reserved.
46 .\"
47 .TH CMP 1 "Jul 19, 2006"
48 .SH NAME
49 cmp \- compare two files
50 .SH SYNOPSIS
51 .LP
52 .nf
53 \fBcmp\fR [\fB-l\fR | \fB-s\fR] \fIfile1\fR \fIfile2\fR [\fIskip1\fR] [\fIskip2\fR]
54 .fi
56 .SH DESCRIPTION
57 .sp
58 .LP
59 The \fBcmp\fR utility compares two files. \fBcmp\fR writes no output if the
60 files are the same. Under default options, if they differ, it writes to
61 standard output the byte and line numbers at which the first difference
62 occurred. Bytes and lines are numbered beginning with 1. If one file is an
63 initial subsequence of the other, that fact is noted. \fIskip1\fR and
64 \fIskip2\fR are initial byte offsets into \fIfile1\fR and \fIfile2\fR
65 respectively, and can be either octal or decimal. A leading 0 denotes octal.
66 .SH OPTIONS
67 .sp
68 .LP
69 The following options are supported:
70 .sp
71 .ne 2
72 .na
73 \fB\fB-l\fR\fR
74 .ad
75 .RS 6n
76 Write the byte number (decimal) and the differing bytes (octal) for each
77 difference.
78 .RE
80 .sp
81 .ne 2
82 .na
83 \fB\fB-s\fR\fR
84 .ad
85 .RS 6n
86 Write nothing for differing files. Return exit status only.
87 .RE
89 .SH OPERANDS
90 .sp
91 .LP
92 The following operands are supported:
93 .sp
94 .ne 2
95 .na
96 \fB\fIfile1\fR\fR
97 .ad
98 .RS 9n
99 A path name of the first file to be compared. If \fIfile1\fR is \fB\(mi\fR, the
100 standard input is used.
104 .ne 2
106 \fB\fIfile2\fR\fR
108 .RS 9n
109 A path name of the second file to be compared. If \fIfile2\fR is \fB\(mi\fR,
110 the standard input is used.
115 If both \fIfile1\fR and \fIfile2\fR refer to standard input or refer to the
116 same \fBFIFO\fR special, block special or character special file, an error
117 results.
118 .SH USAGE
121 See \fBlargefile\fR(5) for the description of the behavior of \fBcmp\fR when
122 encountering files greater than or equal to 2 Gbyte (2^31 bytes).
123 .SH EXAMPLES
125 \fBExample 1 \fRComparing Files Byte for Byte
128 The following example does a byte for byte comparison of \fIfile1\fR and
129 \fIfile2\fR:
132 .in +2
134 example% \fBcmp file1 file2 0 1024\fR
136 .in -2
141 It skips the first 1024 bytes in \fIfile2\fR before starting the comparison.
143 .SH ENVIRONMENT VARIABLES
146 See \fBenviron\fR(5) for descriptions of the following environment variables
147 that affect the execution of \fBcmp\fR: \fBLANG\fR, \fBLC_ALL\fR,
148 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
149 .SH EXIT STATUS
152 The following error values are returned:
154 .ne 2
156 \fB\fB0\fR\fR
158 .RS 6n
159 The files are identical.
163 .ne 2
165 \fB\fB1\fR\fR
167 .RS 6n
168 The files are different. This includes the case where one file is identical to
169 the first part of the other.
173 .ne 2
175 \fB\fB>1\fR\fR
177 .RS 6n
178 An error occurred.
181 .SH ATTRIBUTES
184 See \fBattributes\fR(5) for descriptions of the following attributes:
189 box;
190 c | c
191 l | l .
192 ATTRIBUTE TYPE  ATTRIBUTE VALUE
194 CSI     Enabled
196 Interface Stability     Standard
199 .SH SEE ALSO
202 \fBcomm\fR(1), \fBdiff\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),
203 \fBlargefile\fR(5), \fBstandards\fR(5)