blob: c1b5e849a08f9631c14bd6bf430cbc610298817d [file] [log] [blame]
rsccfa37a72004-04-10 18:53:55 +00001.TH DIFF 1
2.SH NAME
3diff \- differential file comparator
4.SH SYNOPSIS
5.B diff
6[
7.B -efmnbwr
8] file1 ... file2
9.SH DESCRIPTION
10.I Diff
11tells what lines must be changed in two files to bring them
12into agreement.
13If one file
14is a directory,
15then a file in that directory with basename the same as that of
16the other file is used.
17If both files are directories, similarly named files in the
18two directories are compared by the method of
19.I diff
20for text
21files and
22.IR cmp (1)
23otherwise.
24If more than two file names are given, then each argument is compared
25to the last argument as above.
26The
27.B -r
28option causes
29.I diff
30to process similarly named subdirectories recursively.
31When processing more than one file,
32.I diff
33prefixes file differences with a single line
34listing the two differing files, in the form of
35a
36.I diff
37command line.
38The
39.B -m
40flag causes this behavior even when processing single files.
41.PP
42The normal output contains lines of these forms:
43.IP "" 5
44.I n1
45.B a
46.I n3,n4
47.br
48.I n1,n2
49.B d
50.I n3
51.br
52.I n1,n2
53.B c
54.I n3,n4
55.PP
56These lines resemble
57.I ed
58commands to convert
59.I file1
60into
61.IR file2 .
62The numbers after the letters pertain to
63.IR file2 .
64In fact, by exchanging `a' for `d' and reading backward
65one may ascertain equally how to convert
66.I file2
67into
68.IR file1 .
69As in
70.IR ed ,
71identical pairs where
72.I n1
73=
74.I n2
75or
76.I n3
77=
78.I n4
79are abbreviated as a single number.
80.PP
81Following each of these lines come all the lines that are
82affected in the first file flagged by `<',
83then all the lines that are affected in the second file
84flagged by `>'.
85.PP
86The
87.B -b
88option causes
89trailing blanks (spaces and tabs) to be ignored
90and other strings of blanks to compare equal.
91The
92.B -w
93option causes all white-space to be removed from input lines
94before applying the difference algorithm.
95.PP
96The
97.B -n
98option prefixes each range with
99.IB file : \fR
100and inserts a space around the
101.BR a ,
102.BR c ,
103and
104.B d
105verbs.
106The
107.B -e
108option produces a script of
109.I "a, c"
110and
111.I d
112commands for the editor
113.IR ed ,
114which will recreate
115.I file2
116from
117.IR file1 .
118The
119.B -f
120option produces a similar script,
121not useful with
122.IR ed ,
123in the opposite order. It may, however, be
124useful as input to a stream-oriented post-processor.
125.PP
126Except in rare circumstances,
127.I diff
128finds a smallest sufficient set of file
129differences.
130.SH FILES
131.B /tmp/diff[12]
132.SH SOURCE
rscb5fdffe2004-04-19 19:22:56 +0000133.B /usr/local/plan9/src/cmd/diff
rsccfa37a72004-04-10 18:53:55 +0000134.SH "SEE ALSO"
135.IR cmp (1),
136.IR comm (1),
137.IR ed (1)
138.SH DIAGNOSTICS
139Exit status is the empty string
140for no differences,
141.L some
142for some,
143and
144.L error
145for trouble.
146.SH BUGS
147Editing scripts produced under the
148.BR -e " or"
149.BR -f " option are naive about"
150creating lines consisting of a single `\fB.\fR'.
151.br
152When running
153.I diff
154on directories, the notion of what is a text
155file is open to debate.