BSD 3 development
[unix-history] / usr / man / man1 / diff.1
CommitLineData
e6817382
BJ
1.TH DIFF 1
2.SH NAME
3diff \- differential file comparator
4.SH SYNOPSIS
5.B diff
6[
7.B \-efbh
8] file1 file2
9.SH DESCRIPTION
10.I Diff
11tells what lines must be changed in two files to bring them
12into agreement.
13If
14.I file1
15.RI ( file2 )
16is `\-', the standard input is used.
17If
18.I file1
19.RI ( file2 )
20is a directory, then a file in that directory
21whose file-name is the same as the file-name of
22.I file2
23.RI ( file1 )
24is used.
25The normal output contains lines of these forms:
26.IP "" 5
27.I n1
28a
29.I n3,n4
30.br
31.I n1,n2
32d
33.I n3
34.br
35.I n1,n2
36c
37.I n3,n4
38.PP
39These lines resemble
40.I ed
41commands to convert
42.I file1
43into
44.IR file2 .
45The numbers after the letters pertain to
46.IR file2 .
47In fact, by exchanging `a' for `d' and reading backward
48one may ascertain equally how to convert
49.I file2
50into
51.IR file1 .
52As in
53.I ed,
54identical pairs where
55.I n1
56=
57.I n2
58or
59.I n3
60=
61.I n4
62are abbreviated as a single number.
63.PP
64Following each of these lines come all the lines that are
65affected in the first file flagged by `<',
66then all the lines that are affected in the second file
67flagged by `>'.
68.PP
69The
70.B \-b
71option causes
72trailing blanks (spaces and tabs) to be ignored
73and other strings of blanks to compare equal.
74.PP
75The
76.B \-e
77option produces a script of
78.I "a, c"
79and
80.I d
81commands for the editor
82.I ed,
83which will recreate
84.I file2
85from
86.IR file1 .
87The
88.B \-f
89option produces a similar script,
90not useful with
91.I ed,
92in the opposite order.
93In connection with
94.BR \-e ,
95the following shell program may help maintain
96multiple versions of a file.
97Only an ancestral file ($1) and a chain of
98version-to-version
99.I ed
100scripts ($2,$3,...) made by
101.I diff
102need be on hand.
103A `latest version' appears on
104the standard output.
105.IP "" 5
106(shift; cat $*; echo \'1,$p\') \(bv ed \- $1
107.PP
108Except in rare circumstances,
109.I diff
110finds a smallest sufficient set of file
111differences.
112.PP
113Option
114.B \-h
115does a fast, half-hearted job.
116It works only when changed stretches are short
117and well separated,
118but does work on files of unlimited length.
119Options
120.B \-e
121and
122.B \-f
123are unavailable with
124.BR \-h .
125.SH FILES
126/tmp/d?????
127.br
128/usr/lib/diffh for
129.B \-h
130.SH "SEE ALSO"
131cmp(1), comm(1), ed(1)
132.SH DIAGNOSTICS
133Exit status is 0 for no differences, 1 for some, 2 for trouble.
134.SH BUGS
135Editing scripts produced under the
136.BR \-e " or"
137.BR \-f " option are naive about"
138creating lines consisting of a single `\fB.\fR'.