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