9070 Remove wanboot from gate
[unleashed.git] / usr / src / man / man1 / diff.1
blobea4ee76950ccef1d1bf81edf3d39a56d27f30eab
1 '\" te
2 .\"  Copyright 1989 AT&T  Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved  Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH DIFF 1 "Sep 22, 2004"
11 .SH NAME
12 diff \- compare two files
13 .SH SYNOPSIS
14 .LP
15 .nf
16 \fBdiff\fR [\fB-bitw\fR] [\fB-c\fR | \fB-e\fR | \fB-f\fR | \fB-h\fR | \fB-n\fR | \fB-u\fR] \fIfile1\fR \fIfile2\fR
17 .fi
19 .LP
20 .nf
21 \fBdiff\fR [\fB-bitw\fR] [\fB-C\fR \fInumber\fR | \fB-U\fR \fInumber\fR] \fIfile1\fR \fIfile2\fR
22 .fi
24 .LP
25 .nf
26 \fBdiff\fR [\fB-bitw\fR] [\fB-D\fR \fIstring\fR] \fIfile1\fR \fIfile2\fR
27 .fi
29 .LP
30 .nf
31 \fBdiff\fR [\fB-bitw\fR] [\fB-c\fR | \fB-e\fR | \fB-f\fR | \fB-h\fR | \fB-n\fR | \fB-u\fR] [\fB-l\fR] [\fB-r\fR] [\fB-s\fR]
32      [\fB-S\fR \fIname\fR] \fIdirectory1\fR \fIdirectory2\fR
33 .fi
35 .SH DESCRIPTION
36 .sp
37 .LP
38 The \fBdiff\fR utility will compare the contents of \fIfile1\fR and \fIfile2\fR
39 and write to standard output a list of changes necessary to convert \fIfile1\fR
40 into \fIfile2\fR. This list should be minimal. Except in rare circumstances,
41 \fBdiff\fR finds a smallest sufficient set of file differences. No output will
42 be produced if the files are identical.
43 .sp
44 .LP
45 The normal output contains lines of these forms:
46 .sp
47 .in +2
48 .nf
49 \fIn1\fR \fBa\fR \fIn3,n4\fR
50 \fIn1,n2\fR \fBd\fR \fIn3\fR
51 \fIn1,n2\fR \fBc\fR \fIn3,n4\fR
52 .fi
53 .in -2
54 .sp
56 .sp
57 .LP
58 where \fIn1\fR and \fIn2\fR represent lines \fIfile1\fR and \fIn3\fR and
59 \fIn4\fR represent lines in \fIfile2\fR These lines resemble \fBed\fR(1)
60 commands to convert \fIfile1\fR to \fIfile2\fR. By exchanging \fBa\fR for
61 \fBd\fR and reading backward, \fIfile2\fR can be converted to \fIfile1\fR. As
62 in \fBed\fR, identical pairs, where \fIn1\fR=\fIn2\fR or \fIn3\fR=\fIn4\fR, are
63 abbreviated as a single number.
64 .sp
65 .LP
66 Following each of these lines come all the lines that are affected in the first
67 file flagged by `\|\fB<\fR\|', then all the lines that are affected in the
68 second file flagged by `\|\fB>\fR\|'.
69 .SH OPTIONS
70 .sp
71 .LP
72 The following options are supported:
73 .sp
74 .ne 2
75 .na
76 \fB\fB-b\fR \fR
77 .ad
78 .RS 7n
79 Ignores trailing blanks (spaces and tabs) and treats other strings of blanks as
80 equivalent.
81 .RE
83 .sp
84 .ne 2
85 .na
86 \fB\fB-i\fR \fR
87 .ad
88 .RS 7n
89 Ignores the case of letters. For example, `\fBA\fR' will compare equal to
90 `\fBa\fR'.
91 .RE
93 .sp
94 .ne 2
95 .na
96 \fB\fB-t\fR \fR
97 .ad
98 .RS 7n
99 Expands TAB characters in output lines. Normal or \fB-c\fR output adds
100 character(s) to the front of each line that may adversely affect the
101 indentation of the original source lines and make the output lines difficult to
102 interpret. This option will preserve the original source's indentation.
106 .ne 2
108 \fB\fB-w\fR \fR
110 .RS 7n
111 Ignores all blanks (SPACE and TAB characters) and treats all other strings of
112 blanks as equivalent. For example, `\fBif ( a =\|= b )\fR' will compare equal
113 to `\fBif(a=\|=b)\fR'.
118 The following options are mutually exclusive:
120 .ne 2
122 \fB\fB-c\fR \fR
124 .RS 14n
125 Produces a listing of differences with three lines of context. With this
126 option, output format is modified slightly. That is, output begins with
127 identification of the files involved and their creation dates, then each change
128 is separated by a line with a dozen \fB*\fR's. The lines removed from
129 \fIfile1\fR are marked with '\(em'. The lines added to \fIfile2\fR are
130 marked '\|+\|'. Lines that are changed from one file to the other are marked in both
131 files with '\|!\|'.
135 .ne 2
137 \fB\fB-C\fR \fInumber\fR \fR
139 .RS 14n
140 Produces a listing of differences identical to that produced by \fB-c\fR with
141 \fInumber\fR lines of context.
145 .ne 2
147 \fB\fB-D\fR \fIstring\fR \fR
149 .RS 14n
150 Creates a merged version of \fIfile1\fR and \fIfile2\fR with C preprocessor
151 controls included so that a compilation of the result without defining
152 \fIstring\fR is equivalent to compiling \fIfile1\fR, while defining
153 \fIstring\fR will yield \fIfile2\fR.
157 .ne 2
159 \fB\fB-e\fR \fR
161 .RS 14n
162 Produces a script of only \fBa\fR, \fBc\fR, and \fBd\fR commands for the editor
163 \fBed\fR, which will recreate \fIfile2\fR from \fIfile1\fR. In connection with
164 the \fB-e\fR option, the following shell program may help maintain multiple
165 versions of a file. Only an ancestral file ($1) and a chain of
166 version-to-version \fBed\fR scripts ($2,$3,...) made by \fBdiff\fR need be on
167 hand. A ``latest version'' appears on the standard output.
169 .in +2
171 (shift; cat $*; echo a\'1,$p') | ed \(mi $1
173 .in -2
179 .ne 2
181 \fB\fB-f\fR \fR
183 .RS 13n
184 Produces a similar script, not useful with \fBed\fR, in the opposite order.
188 .ne 2
190 \fB\fB-h\fR \fR
192 .RS 13n
193 Does a fast, half-hearted job. It works only when changed stretches are short
194 and well separated, but does work on files of unlimited length. Options
195 \fB-c\fR, \fB-C\fR, \fB-D\fR, \fB-e\fR, \fB-f\fR, and \fB-n\fR are unavailable
196 with \fB-h\fR. \fBdiff\fR does not descend into directories with this option.
200 .ne 2
202 \fB\fB-n\fR \fR
204 .RS 13n
205 Produces a script similar to \fB-e\fR, but in the opposite order and with a
206 count of changed lines on each insert or delete command.
210 .ne 2
212 \fB\fB-u\fR\fR
214 .RS 13n
215 Produces a listing of differences with three lines of context. The output is
216 similar to that of the \fB-c\fR option, except that the context is "unified".
217 Removed and changed lines in \fIfile1\fR are marked by a '\fB-\fR' while lines
218 added or changed in \fIfile2\fR are marked by a '\fB+\fR'. Both versions of
219 changed lines appear in the output, while added, removed, and context lines
220 appear only once. The identification of \fIfile1\fR and \fIfile2\fR is
221 different, with "\fB\(mi\(mi\(mi\fR" and "\fB+++\fR" being printed where
222 "\fB***\fR" and "\fB\(mi\(mi\(mi\fR" would appear with the \fB-c\fR option.
223 Each change is separated by a line of the form
225 .in +2
227 \fB@@ -\fIn1\fR,\fIn2\fR +\fIn3\fR,\fIn4\fR @@\fR
229 .in -2
235 .ne 2
237 \fB\fB-U\fR \fInumber\fR\fR
239 .RS 13n
240 Produces a listing of differences identical to that produced by \fB-u\fR with
241 \fInumber\fR lines of context.
246 The following options are used for comparing directories:
248 .ne 2
250 \fB\fB-l\fR \fR
252 .RS 12n
253 Produces output in long format. Before the \fBdiff\fR, each text file is piped
254 through \fBpr\fR(1) to paginate it. Other differences are remembered and
255 summarized after all text file differences are reported.
259 .ne 2
261 \fB\fB-r\fR \fR
263 .RS 12n
264 Applies \fBdiff\fR recursively to common subdirectories encountered.
268 .ne 2
270 \fB\fB-s\fR \fR
272 .RS 12n
273 Reports files that are identical. These identical files would not otherwise be
274 mentioned.
278 .ne 2
280 \fB\fB-S\fR \fIname\fR \fR
282 .RS 12n
283 Starts a directory \fBdiff\fR in the middle, beginning with the file
284 \fIname\fR.
287 .SH OPERANDS
290 The following operands are supported:
292 .ne 2
294 \fB\fIfile1\fR \fR
298 \fB\fIfile2\fR\fR
300 .RS 15n
301 A path name of a file or directory to be compared. If either \fIfile1\fR or
302 \fIfile2\fR is \fB\(mi\fR, the standard input will be used in its place.
306 .ne 2
308 \fB\fIdirectory1\fR \fR
312 \fB\fIdirectory2\fR\fR
314 .RS 15n
315 A path name of a directory to be compared.
320 If only one of \fIfile1\fR and \fIfile2\fR is a directory, \fBdiff\fR will be
321 applied to the non-directory file and the file contained in the directory file
322 with a filename that is the same as the last component of the non-directory
323 file.
324 .SH USAGE
327 See \fBlargefile\fR(5) for the description of the behavior of \fBdiff\fR when
328 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
329 .SH EXAMPLES
331 \fBExample 1 \fRTypical output of the diff command
334 In the following command, \fBdir1\fR is a directory containing a directory
335 named \fBx\fR, \fBdir2\fR is a directory containing a directory named \fBx\fR,
336 \fBdir1/x\fR and \fBdir2/x\fR both contain files named \fBdate.out\fR, and
337 \fBdir2/x\fR contains a file named \fBy\fR:
340 .in +2
342 example% \fBdiff -r dir1 dir2\fR
343 Common subdirectories: dir1/x and dir2/x
345 Only in dir2/x: y
347 diff -r dir1/x/date.out dir2/x/date.out
351 < Mon Jul  2 13:12:16 PDT 1990
355 > Tue Jun 19 21:41:39 PDT 1990
357 .in -2
360 .SH ENVIRONMENT VARIABLES
363 See \fBenviron\fR(5) for descriptions of the following environment variables
364 that affect the execution of \fBdiff\fR: \fBLANG\fR, \fBLC_ALL\fR,
365 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBLC_TIME\fR, and \fBNLSPATH\fR.
367 .ne 2
369 \fB\fBTZ\fR \fR
371 .RS 7n
372 Determines the locale for affecting the timezone used for calculating file
373 timestamps written with the \fB-C\fR and \fB-c\fR options.
376 .SH EXIT STATUS
379 The following exit values are returned:
381 .ne 2
383 \fB\fB0\fR \fR
385 .RS 7n
386 No differences were found.
390 .ne 2
392 \fB\fB1\fR \fR
394 .RS 7n
395 Differences were found.
399 .ne 2
401 \fB\fB>1\fR \fR
403 .RS 7n
404 An error occurred.
407 .SH FILES
409 .ne 2
411 \fB\fB/tmp/d?????\fR \fR
413 .RS 19n
414 temporary file used for comparison
418 .ne 2
420 \fB\fB/usr/lib/diffh\fR \fR
422 .RS 19n
423 executable file for \fB-h\fR option
426 .SH ATTRIBUTES
429 See \fBattributes\fR(5) for descriptions of the following attributes:
434 box;
435 c | c
436 l | l .
437 ATTRIBUTE TYPE  ATTRIBUTE VALUE
439 CSI     Enabled
441 Interface Stability     Standard
444 .SH SEE ALSO
447 \fBbdiff\fR(1), \fBcmp\fR(1), \fBcomm\fR(1), \fBdircmp\fR(1), \fBed\fR(1),
448 \fBpr\fR(1), \fBsdiff\fR(1), \fBattributes\fR(5), \fBenviron\fR(5),
449 \fBlargefile\fR(5), \fBstandards\fR(5)
450 .SH NOTES
453 Editing scripts produced under the \fB-e\fR or \fB-f\fR options are naive about
454 creating lines consisting of a single period (\fB\&.\fR).
457 Missing NEWLINE at end of file indicates that the last line of the file in
458 question did not have a NEWLINE. If the lines are different, they will be
459 flagged and output, although the output will seem to indicate they are the
460 same.