1DIFF(1) General Commands Manual DIFF(1)
2
3
4
6 diff - differential file comparator
7
9 diff [ -efbh ] file1 file2
10
12 Diff tells what lines must be changed in two files to bring them into
13 agreement. If file1 (file2) is `-', the standard input is used. If
14 file1 (file2) is a directory, then a file in that directory whose file-
15 name is the same as the file-name of file2 (file1) is used. The normal
16 output contains lines of these forms:
17
18 n1 a n3,n4
19 n1,n2 d n3
20 n1,n2 c n3,n4
21
22 These lines resemble ed commands to convert file1 into file2. The num‐
23 bers after the letters pertain to file2. In fact, by exchanging `a'
24 for `d' and reading backward one may ascertain equally how to convert
25 file2 into file1. As in ed, identical pairs where n1 = n2 or n3 = n4
26 are abbreviated as a single number.
27
28 Following each of these lines come all the lines that are affected in
29 the first file flagged by `<', then all the lines that are affected in
30 the second file flagged by `>'.
31
32 The -b option causes trailing blanks (spaces and tabs) to be ignored
33 and other strings of blanks to compare equal.
34
35 The -e option produces a script of a, c and d commands for the editor
36 ed, which will recreate file2 from file1. The -f option produces a
37 similar script, not useful with ed, in the opposite order. In connec‐
38 tion with -e, the following shell program may help maintain multiple
39 versions of a file. Only an ancestral file ($1) and a chain of ver‐
40 sion-to-version ed scripts ($2,$3,...) made by diff need be on hand. A
41 `latest version' appears on the standard output.
42
43 (shift; cat $*; echo ´1,$p´) ⎪ ed - $1
44
45 Except in rare circumstances, diff finds a smallest sufficient set of
46 file differences.
47
48 Option -h does a fast, half-hearted job. It works only when changed
49 stretches are short and well separated, but does work on files of
50 unlimited length. Options -e and -f are unavailable with -h.
51
53 /tmp/d?????
54 /usr/lib/diffh for -h
55
57 cmp(1), comm(1), ed(1)
58
60 Exit status is 0 for no differences, 1 for some, 2 for trouble.
61
63 Editing scripts produced under the -e or -f option are naive about cre‐
64 ating lines consisting of a single `.'.
65
66
67
68 DIFF(1)