|
|
1.1 root 1: .\" Copyright (c) 1980 Regents of the University of California.
2: .\" All rights reserved. The Berkeley software License Agreement
3: .\" specifies the terms and conditions for redistribution.
4: .\"
5: .\" @(#)diff.1 6.4 (Berkeley) 5/19/86
6: .\"
7: .TH DIFF 1 "May 19, 1986"
8: .UC 4
9: .SH NAME
10: diff \- differential file and directory comparator
11: .SH SYNOPSIS
12: .B diff
13: [
14: .B \-l
15: ] [
16: .B \-r
17: ] [
18: .B \-s
19: ] [
20: \fB\-cefhn\fR
21: ] [
22: .B \-biwt
23: ] dir1 dir2
24: .br
25: .B diff
26: [
27: \fB\-cefhn
28: ] [
29: \fB\-biwt\fR
30: ] file1 file2
31: .br
32: .B diff
33: [
34: .BI \-D string
35: ] [
36: .B \-biw
37: ]
38: file1 file2
39: .SH DESCRIPTION
40: If both arguments are directories,
41: .I diff
42: sorts the contents of the directories by name, and then runs the
43: regular file
44: .I diff
45: algorithm (described below)
46: on text files which are different.
47: Binary files which differ,
48: common subdirectories, and files which appear in only one directory
49: are listed.
50: Options when comparing directories are:
51: .TP
52: .B \-l
53: long output format; each text file
54: .I diff
55: is piped through
56: .IR pr (1)
57: to paginate it,
58: other differences are remembered and summarized
59: after all text file differences are reported.
60: .TP
61: .B \-r
62: causes application of
63: .I diff
64: recursively to common subdirectories encountered.
65: .TP
66: .B \-s
67: causes
68: .I diff
69: to report files which are the same, which are otherwise not mentioned.
70: .TP
71: .B \-Sname
72: starts a directory
73: .I diff
74: in the middle beginning with file
75: .I name.
76: .PP
77: When run on regular files, and when comparing text files which differ
78: during directory comparison,
79: .I diff
80: tells what lines must be changed in the files to bring them into agreement.
81: Except in rare circumstances,
82: .I diff
83: finds a smallest sufficient set of file differences.
84: If neither
85: .I file1
86: nor
87: .I file2
88: is a directory, then either
89: may be given as `\-', in which case the standard input is used.
90: If
91: .I file1
92: is a directory,
93: then a file in that directory whose file-name is the same as the file-name of
94: .I file2
95: is used (and vice versa).
96: .PP
97: There are several options for output format;
98: the default output format contains lines of these forms:
99: .IP "" 5
100: .I n1
101: a
102: .I n3,n4
103: .br
104: .I n1,n2
105: d
106: .I n3
107: .br
108: .I n1,n2
109: c
110: .I n3,n4
111: .PP
112: These lines resemble
113: .I ed
114: commands to convert
115: .I file1
116: into
117: .IR file2 .
118: The numbers after the letters pertain to
119: .IR file2 .
120: In fact, by exchanging `a' for `d' and reading backward
121: one may ascertain equally how to convert
122: .I file2
123: into
124: .IR file1 .
125: As in
126: .I ed,
127: identical pairs where
128: .I n1
129: =
130: .I n2
131: or
132: .I n3
133: =
134: .I n4
135: are abbreviated as a single number.
136: .PP
137: Following each of these lines come all the lines that are
138: affected in the first file flagged by `<',
139: then all the lines that are affected in the second file
140: flagged by `>'.
141: .PP
142: Except for
143: \fB\-b, -w, -i\fP or \fB-t\fP
144: which may be given with any of the others,
145: the following options are mutually exclusive:
146: .TP 9
147: .B \-e
148: produces a script of
149: .I "a, c"
150: and
151: .I d
152: commands for the editor
153: .I ed,
154: which will recreate
155: .I file2
156: from
157: .IR file1 .
158: In connection with
159: .BR \-e ,
160: the following shell program may help maintain
161: multiple versions of a file.
162: Only an ancestral file ($1) and a chain of
163: version-to-version
164: .I ed
165: scripts ($2,$3,...) made by
166: .I diff
167: need be on hand.
168: A `latest version' appears on
169: the standard output.
170: .IP
171: \ \ \ \ \ \ \ \ (shift; cat $*; echo \'1,$p\') \(bv ed \- $1
172: .IP
173: Extra commands are added to the output when comparing directories with
174: .B \-e,
175: so that the result is a
176: .IR sh (1)
177: script for converting text files which are common to the two directories
178: from their state in
179: .I dir1
180: to their state in
181: .I dir2.
182: .TP 9
183: .B \-f
184: produces a script similar to that of
185: .B \-e,
186: not useful with
187: .I ed,
188: and in the opposite order.
189: .TP 9
190: .B \-n
191: produces a script similar to that of
192: .B \-e,
193: but in the opposite order and with a count of changed lines on each
194: insert or delete command. This is the form used by
195: .IR rcsdiff (1).
196: .TP 9
197: .B \-c
198: produces a diff with lines of context.
199: The default is to present 3 lines of context and may be changed, e.g to 10, by
200: .BR \-c10 \&.
201: With
202: .B \-c
203: the output format is modified slightly:
204: the output beginning with identification of the files involved and
205: their creation dates and then each change is separated
206: by a line with a dozen *'s.
207: The lines removed from
208: .I file1
209: are marked with `\(mi '; those added to
210: .I file2
211: are marked `+ '. Lines which are changed from one
212: file to the other are marked in both files with with `! '.
213:
214: Changes which lie within <context> lines of each other are grouped
215: together on output. (This is a change from the previous ``diff -c''
216: but the resulting output is usually much easier to interpret.)
217: .TP 9
218: .B \-h
219: does a fast, half-hearted job.
220: It works only when changed stretches are short
221: and well separated,
222: but does work on files of unlimited length.
223: .TP
224: .B \-Dstring
225: causes
226: .I diff
227: to create a merged version of
228: .I file1
229: and
230: .I file2
231: on the standard output, with C preprocessor controls included so that
232: a compilation of the result without defining \fIstring\fR is equivalent
233: to compiling
234: .I file1,
235: while defining
236: .I string
237: will yield
238: .I file2.
239: .TP 9
240: .B \-b
241: causes trailing blanks (spaces and tabs) to be ignored, and other
242: strings of blanks to compare equal.
243: .TP 9
244: .B \-w
245: is similar to
246: .B \-b
247: but causes whitespace (blanks and tabs) to be totally ignored. E.g.,
248: ``if\ (\ a\ ==\ b\ )'' will compare equal to ``if(a==b)''.
249: .TP 9
250: .B \-i
251: ignores the case of letters. E.g., ``A'' will compare equal to ``a''.
252: .TP 9
253: .B \-t
254: will expand tabs in output lines. Normal or
255: .B \-c
256: output adds character(s) to the front of each line which may screw up
257: the indentation of the original source lines and make the output listing
258: difficult to interpret. This option will preserve the original source's
259: indentation.
260: .SH FILES
261: /tmp/d?????
262: .br
263: /usr/lib/diffh for
264: .B \-h
265: .br
266: /bin/diff for directory diffs
267: .br
268: /bin/pr
269: .SH "SEE ALSO"
270: cmp(1), cc(1), comm(1), ed(1), diff3(1)
271: .SH DIAGNOSTICS
272: Exit status is 0 for no differences, 1 for some, 2 for trouble.
273: .SH BUGS
274: Editing scripts produced under the
275: .BR \-e " or"
276: .BR \-f " option are naive about"
277: creating lines consisting of a single `\fB.\fR'.
278: .PP
279: When comparing directories with the
280: \fB\-b, -w\fP or \fB-i\fP
281: options specified,
282: .I diff
283: first compares the files ala
284: .I cmp,
285: and then decides to run the
286: .I diff
287: algorithm if they are not equal.
288: This may cause a small amount of spurious output if the files
289: then turn out to be identical because the only differences are
290: insignificant blank string or case differences.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.