|
|
1.1 root 1: .TH DIFF 1
2: .CT 1 files
3: .SH NAME
4: diff, diff3 \- differential file comparison
5: .SH SYNOPSIS
6: .B diff
7: [
8: .I option ...
9: ]
10: .I file1 file2
11: .PP
12: .B diff3
13: [
14: .B \-ex3
15: ]
16: .I file1 file2 file3
17: .SH DESCRIPTION
18: When run on regular files
19: .I diff
20: tells what lines must be changed in the files to bring them into agreement.
21: Except in rare circumstances,
22: .I diff
23: finds a smallest sufficient set of differences.
24: If neither file
25: is a directory, then one
26: may be
27: .LR - ,
28: meaning the standard input.
29: If one file
30: is a directory,
31: then a file in that directory with basename the same as that of
32: the other file is used.
33: .PP
34: If both files are directories,
35: similarly named files in the two directories
36: are compared by the method of
37: .I diff
38: for text files and
39: .IR cmp (1)
40: otherwise.
41: Options when comparing directories are:
42: .TP
43: .B -r
44: Apply
45: .I diff
46: recursively to similarly named subdirectories.
47: .TP
48: .B -s
49: Report files that are the same (normally not mentioned).
50: .PP
51: There are several options for output format;
52: the default output format contains lines of these forms:
53: .IP
54: .IB n1 a
55: .IB n3 , n4
56: .br
57: .IB n1 , n2 d
58: .I n3
59: .br
60: .IB n1 , n2 c
61: .IB n3 , n4
62: .PP
63: These lines resemble
64: .I ed
65: commands to convert
66: .I file1
67: into
68: .IR file2 .
69: The numbers after the letters pertain to
70: .IR file2 .
71: In fact, by exchanging
72: .L a
73: for
74: .L d
75: and reading backward
76: one may ascertain equally how to convert
77: .I file2
78: into
79: .IR file1 .
80: As in
81: .I ed,
82: identical pairs where
83: .IR n1 = n2
84: or
85: .I n3 = n4
86: are abbreviated as a single number.
87: .PP
88: Following each of these lines come all the lines that are
89: affected in the first file flagged by
90: .LR < ,
91: then all the lines that are affected in the second file
92: flagged by
93: .LR > .
94: .PP
95: .TP
96: .B -e
97: Produce a script of
98: .LR a ,
99: .LR c ,
100: and
101: .L d
102: for
103: .IR ed (1)
104: to recreate
105: .I file2
106: from
107: .IR file1 .
108: When comparing directories, produce a
109: .IR sh (1)
110: script to convert text files common to the two directories.
111: .TP
112: .BI -c n
113: Include
114: .I n
115: extra lines of context with each set of differences.
116: The output format is modified:
117: the output begins with identification of the files involved and
118: their creation dates and changes are separated
119: by lines of *'s.
120: Lines removed from
121: .I file1
122: are marked with
123: .LR - ;
124: those added to
125: .I file2
126: are marked
127: .LR + .
128: Lines which are changed from one
129: file to the other are marked in both files with
130: .LR ! .
131: .TP
132: .B -h
133: Do a fast, half-hearted job,
134: useful only when changed stretches are short
135: and well separated,
136: but does work on files of unlimited length.
137: .TP
138: .B -b
139: Ignore trailing blanks (spaces and tabs) and treat other
140: strings of blanks as if they were a single space.
141: .TP
142: .B -B
143: Ignore all blanks.
144: .PP
145: .I Diff3
146: compares three versions of a file
147: and publishes the various disagreeing ranges of text.
148: One of the following indicators introduces each reported
149: difference.
150: .TP
151: .B ====
152: All three files differ.
153: .TP
154: .BI ==== f
155: File
156: .I f
157: differs, where
158: .I f
159: is 1, 2, or 3.
160: .PP
161: Disagreeing fragments from the three files follow the
162: .B ====
163: line, each identified by a
164: .IR diff -like
165: range indication:
166: .TP
167: .IB f : n1 a
168: File
169: .I f
170: lacks text that other files have; their text would
171: be appended after line
172: .I n1.
173: .TP
174: .IB f : n1 , n2 c
175: .br
176: .ns
177: .TP
178: .IB f : n1 c
179: Lines
180: .I n1
181: through
182: .I n2
183: (or line
184: .I n1
185: only) of file
186: .I f
187: would have to be changed to agree with some other file.
188: The original contents follow, unless a higher-numbered file
189: has the same contents.
190: .PP
191: Under option
192: .BR -e ,
193: .I diff3
194: publishes a script for
195: .IR ed (1)
196: that will incorporate into
197: .I file1
198: all changes between
199: .I file2
200: and
201: .I file3,
202: i.e. the changes that normally would be flagged
203: .B ====
204: and
205: .BR ====3 .
206: Option
207: .B \-x
208: (\fB\-3\fR)
209: produces a script to incorporate
210: only changes flagged
211: .B ====
212: .RB ( ====3 ).
213: .SH EXAMPLES
214: .TP
215: .L
216: (cat diff0-1 diff1-2 diff2-3; echo '1,$p') | ed - file0 >file3
217: An ancestral
218: .L file0
219: has been kept along with a chain of version-to-version
220: difference files made thus:
221: .LR "diff -e file0 file1 >diff0-1" .
222: The shell command reconstructs the latest version.
223: .PP
224: .EX
225: if diff3 mod1 old mod2 | grep -s '^====$'
226: then :
227: else (diff3 -e mod1 old mod2; echo '1,$p') | ed - mod1 >new
228: fi
229: .EE
230: .PD0
231: .IP
232: Compare two different modified versions with an old file.
233: If no modifications interfere with each other
234: .RI ( grep
235: finds no
236: .B ====
237: lines), make a new file incorporating both modifications.
238: .PD
239: .SH FILES
240: .F /tmp/d*
241: .br
242: .F /usr/lib/diffh
243: for
244: .B -h
245: .br
246: .F /usr/lib/diff3
247: .SH "SEE ALSO"
248: .IR cmp (1),
249: .IR comm (1),
250: .IR ed (1),
251: .IR idiff (1)
252: .SH DIAGNOSTICS
253: .I Diff
254: yields exit status is 0 for no differences, 1 for some, 2 for trouble.
255: .SH BUGS
256: Text lines that consist of a single `.' will
257: defeat options
258: .BR -e ,
259: .BR -x ,
260: and
261: .BR -3 .
262: .br
263: Superfluous output may result for files that differ
264: only in insignificant blanks when comparing directories
265: under option
266: .BR -b .
267: .br
268: Option
269: .B -c
270: is unpardonably bizarre.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.