ucbdiff(1) ucbdiff(1)NAME ucbdiff - differential file and directory comparator SYNOPSIS ucbdiff [-l] [-r] [-s] [-Sname] [-cefhn] [-biwt] dir1 dir2 ucbdiff [-cefhn] [-biwt] file1 file2 ucbdiff [-Dstring] [-biw] file1 file2 DESCRIPTION ucbdiff is used by the rcs(1) Revision Control System. If both arguments are directories, ucbdiff sorts the contents of the directories by name and then runs the regular file diff algorithm (described later in this section) on text files which are different. Binary files which differ, com- mon subdirectories, and files which appear in only one directory are listed. Options, when comparing directories, are: -l Long output format; each set of text file differences is piped through pr(1) to paginate the output; other differences are remembered and summarized after all text file differences are reported. -r Causes application of ucbdiff recursively to common subdirectories encountered. -s Causes ucbdiff to report files which are the same and are otherwise not mentioned. -Sname Starts a directory ucbdiff in the middle, beginning with the file name. When run on regular files and when comparing text files which differ during directory comparison, ucbdiff tells what lines must be changed in the files to bring them into agree- ment. Except in rare circumstances, ucbdiff finds the smal- lest sufficient set of file differences. If neither file1 nor file2 is a directory, then either may be given as -, in which case the standard input is used. If file1 is a direc- tory, then a file in that directory whose filename is the same as the filename of file2 is used (and vice versa). There are several options for output format; the default output format contains lines of these forms n1 a n3,n4 n1,n2 d n3 n1,n2 c n3,n4 These lines resemble ed commands to convert file1 into file2. The numbers after the letters pertain to file2. In April, 1990 1
ucbdiff(1) ucbdiff(1)fact, by exchanging a for d and reading backward, one may ascertain how to equally convert file2 into file1. As in ed, identical pairs (where n1=n2 or n3=n4) are abbreviated as a single number. Following each of these lines are all the lines affected in the first file flagged by <, then all the lines that are af- fected in the second file flagged by >. Except for -b, -w, -i, or -t (which may be given with any of the others), the following options are mutually exclusive. -e Produces a script of a, c, and d commands for the editor ed, which will recreate file2 from file1. In connection with -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 ed scripts ($2, $3,...) made by ucbdiff need be on hand. A ``latest version'' ap- pears on the standard output. (shift;cat $*;echo '1,$p')|ed - $1 Extra commands are added to the output when compar- ing directories with -e, so that the result is a sh(1) script for converting text files common to the two directories from their state in dir1 to their state in dir2. -f Produces a script similar to that of -e, but in the opposite order and not useful with ed. -n Produces a script similar to that of -e, but in the opposite order and with a count of changed lines on each insert or delete command. This is the form used by rcsdiff(1). -c Produces a ucbdiff with lines of context. The de- fault is to present 3 lines of context; this may be changed, for example to 10, by -c10. With -c, the output format is modified slightly. The output be- gins with an identification of the files involved and their creation dates; then each change is separated by a line with a dozen *'s. The lines removed from file1 are marked with a -; those added to file2 are marked +. Lines which are changed from one file to the other are marked in both files with with a !. Changes that are separated by fewer than the number of lines in the current context are grouped together on output. (This is a change from the previous ucbdiff -c but the 2 April, 1990
ucbdiff(1) ucbdiff(1)resulting output is usually much easier to interpret.) -h Does a fast, half-hearted job. It works only when changed stretches are short and well separated, but will work on files of unlimited length. -Dstring Causes ucbdiff to create a merged version of file1 and file2 on the standard output with C preproces- sor controls included, so that a compilation of the result without defining string is equivalent to compiling file1, while defining string will yield file2. -b Causes trailing blanks (spaces and tabs) to be ig- nored and other strings of blanks to compare equal. -w Similar to -b but causes whitespace (blanks and tabs) to be totally ignored. For example, the fol- lowing two lines will compare equal. if ( a == b ) if(a==b) -i Ignores the case of letters. For example, A will compare equal to a. -t Will expand tabs in output lines. Normal or -c output adds character(s) to the front of each line, which may alter the indentation of the original source lines and make the output listing difficult to interpret. This option will preserve the origi- nal source's indentation. FILES /usr/ucb/ucbdiff /tmp/d????? /usr/lib/ucbdiffh for -h /bin/diff for directory comparisons /bin/pr SEE ALSO cc(1), cmp(1), comm(1), diff(1), ed(1), rcs(1), ucbdiff3(1). DIAGNOSTICS Exit status is 0 for no differences, 1 for some, 2 for trou- ble. BUGS Editing scripts produced under the -e or -f option are naive about creating lines consisting of a single period (.). April, 1990 3
ucbdiff(1) ucbdiff(1)When comparing directories with the -b, -w, or -i options specified, ucbdiff first compares the files like cmp and then decides to run the ucbdiff algorithm if they are not equal. This may cause a small amount of spurious output if the files then turn out to be identical because the only differences are insignificant blank string or case differ- ences. 4 April, 1990