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