| diff.1 - 9base - revived minimalist port of Plan 9 userland to Unix | |
| git clone git://git.suckless.org/9base | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| diff.1 (2959B) | |
| --- | |
| 1 .TH DIFF 1 | |
| 2 .SH NAME | |
| 3 diff \- differential file comparator | |
| 4 .SH SYNOPSIS | |
| 5 .B diff | |
| 6 [ | |
| 7 .B -acefmnbwr | |
| 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 one file | |
| 14 is a directory, | |
| 15 then a file in that directory with basename the same as that of | |
| 16 the other file is used. | |
| 17 If both files are directories, similarly named files in the | |
| 18 two directories are compared by the method of | |
| 19 .I diff | |
| 20 for text | |
| 21 files and | |
| 22 .IR cmp (1) | |
| 23 otherwise. | |
| 24 If more than two file names are given, then each argument is compared | |
| 25 to the last argument as above. | |
| 26 The | |
| 27 .B -r | |
| 28 option causes | |
| 29 .I diff | |
| 30 to process similarly named subdirectories recursively. | |
| 31 When processing more than one file, | |
| 32 .I diff | |
| 33 prefixes file differences with a single line | |
| 34 listing the two differing files, in the form of | |
| 35 a | |
| 36 .I diff | |
| 37 command line. | |
| 38 The | |
| 39 .B -m | |
| 40 flag causes this behavior even when processing single files. | |
| 41 .PP | |
| 42 The 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 | |
| 56 These lines resemble | |
| 57 .I ed | |
| 58 commands to convert | |
| 59 .I file1 | |
| 60 into | |
| 61 .IR file2 . | |
| 62 The numbers after the letters pertain to | |
| 63 .IR file2 . | |
| 64 In fact, by exchanging `a' for `d' and reading backward | |
| 65 one may ascertain equally how to convert | |
| 66 .I file2 | |
| 67 into | |
| 68 .IR file1 . | |
| 69 As in | |
| 70 .IR ed , | |
| 71 identical pairs where | |
| 72 .I n1 | |
| 73 = | |
| 74 .I n2 | |
| 75 or | |
| 76 .I n3 | |
| 77 = | |
| 78 .I n4 | |
| 79 are abbreviated as a single number. | |
| 80 .PP | |
| 81 Following each of these lines come all the lines that are | |
| 82 affected in the first file flagged by `<', | |
| 83 then all the lines that are affected in the second file | |
| 84 flagged by `>'. | |
| 85 .PP | |
| 86 The | |
| 87 .B -b | |
| 88 option causes | |
| 89 trailing blanks (spaces and tabs) to be ignored | |
| 90 and other strings of blanks to compare equal. | |
| 91 The | |
| 92 .B -w | |
| 93 option causes all white-space to be removed from input lines | |
| 94 before applying the difference algorithm. | |
| 95 .PP | |
| 96 The | |
| 97 .B -n | |
| 98 option prefixes each range with | |
| 99 .IB file : \fR | |
| 100 and inserts a space around the | |
| 101 .BR a , | |
| 102 .BR c , | |
| 103 and | |
| 104 .B d | |
| 105 verbs. | |
| 106 The | |
| 107 .B -e | |
| 108 option produces a script of | |
| 109 .I "a, c" | |
| 110 and | |
| 111 .I d | |
| 112 commands for the editor | |
| 113 .IR ed , | |
| 114 which will recreate | |
| 115 .I file2 | |
| 116 from | |
| 117 .IR file1 . | |
| 118 The | |
| 119 .B -f | |
| 120 option produces a similar script, | |
| 121 not useful with | |
| 122 .IR ed , | |
| 123 in the opposite order. It may, however, be | |
| 124 useful as input to a stream-oriented post-processor. | |
| 125 .PP | |
| 126 The | |
| 127 .B -c | |
| 128 option includes three lines of context around each | |
| 129 change, merging changes whose contexts overlap. | |
| 130 The | |
| 131 .B -a | |
| 132 flag displays the entire file as context. | |
| 133 .PP | |
| 134 Except in rare circumstances, | |
| 135 .I diff | |
| 136 finds a smallest sufficient set of file | |
| 137 differences. | |
| 138 .SH FILES | |
| 139 .B /tmp/diff[12] | |
| 140 .SH SOURCE | |
| 141 .B \*9/src/cmd/diff | |
| 142 .SH "SEE ALSO" | |
| 143 .IR cmp (1), | |
| 144 .IR comm (1), | |
| 145 .IR ed (1) | |
| 146 .SH DIAGNOSTICS | |
| 147 Exit status is the empty string | |
| 148 for no differences, | |
| 149 .L some | |
| 150 for some, | |
| 151 and | |
| 152 .L error | |
| 153 for trouble. | |
| 154 .SH BUGS | |
| 155 Editing scripts produced under the | |
| 156 .BR -e " or" | |
| 157 .BR -f " option are naive about" | |
| 158 creating lines consisting of a single `\fB.\fR'. | |
| 159 .PP | |
| 160 When running | |
| 161 .I diff | |
| 162 on directories, the notion of what is a text | |
| 163 file is open to debate. |