.th DIFF I 5/31/77 .sh NAME diff \*- differential file comparator .sh SYNOPSIS .bd diff [ .bd \-efb ] name1 name2 .sh DESCRIPTION .it Diff tells what lines must be changed in two files to bring them into agreement. If .it"name1 (name2)" is `\-', the standard input is used. If .it"name1 (name2)" is a directory, then a file in that directory whose file-name is the same as the file-name of .it "name2 (name1)" is used. The normal output contains lines of these forms: .s3 .lp +5 0 .it n1 a .it n3,n4 .br .it n1,n2 d .it n3 .br .it n1,n2 c .it n3,n4 .s3 .i0 These lines resemble .it ed commands to convert file .it name1 into file .it name2. The numbers after the letters pertain to file .it name2. In fact, by exchanging `a' for `d' and reading backward one may ascertain equally how to convert file .it name2 into .it name1. As in .it ed, identical pairs where .it n1 = .it n2 or .it n3 = .it n4 are abbreviated as a single number. .s3 Following each of these lines come all the lines that are affected in the first file flagged by `<', then all the lines that are affected in the second file flagged by `>'. .s3 The .bd \-b option causes trailing blanks (spaces and tabs) to be ignored and other strings of blanks to compare equal. The .bd \-e option produces a script of .it "a, c" and .it d commands for the editor .it ed, which will recreate file .it name2 from file .it name1. The .bd \-f option produces a similar script, not useful with .it ed, in the opposite order. In connection with .bd \-e, the following shell program may help maintain multiple versions of a file. Only an ancestral file ($1) and a chain of version-to-version .it ed scripts ($2,$3,...) made by .it diff need be on hand. A `latest version' appears on the standard output. .s3 .lp +5 0 (cat $2 ... $9; echo \*'1,$p\*') \*v ed \*- $1 .s3 .i0 Except for occasional `jackpots', .it diff finds a smallest sufficient set of file differences. .sh FILES /tmp/d????? .sh "SEE ALSO" cmp(I), comm(I), ed(I), uniq(I) .sh DIAGNOSTICS `jackpot' \- To speed things up, the program uses hashing. You have stumbled on a case where there is a chance that this has resulted in a difference being called where none actually existed. Sometimes reversing the order of files will make a jackpot go away. .sh BUGS Editing scripts produced under the \fB\-e\fR or \fB\-f\fR options are naive about creating lines consisting of a single `\fB.\fR'.