[Chapter 28] 28.7 diff for Very Long Files: bdiff
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:44:45Z

#

| Chapter 28 Comparing Files |

## 28.7 diff for Very Long Files: bdiff

The diff command has trouble comparing very long files. Its -h option does a half-hearted and fast job, but it can miss changes in some cases. System V users have an alternative: bdiff. It ignores lines common to the beginning of both files, splits the remainder of each file into chunks, and runs diff on corresponding segments. (BSD users can probably make a shell script that does this, more or less. I haven't tried, though.) bdiff also adjusts the line numbers for each chunk to make it look like one diff did the whole job.

The good part of this is that bdiff will find all the differences. The bad part is that it might find "differences" that really aren't differences at all. This extra output is usually caused by uneven-length files. Here's an example of two files that aren't quite too long for the regular diff-it finds the single difference correctly. But bdiff finds another "difference" that isn't really a difference:

>     % diff log1 log2
>     11580a11581
>     > 15:25:42: ERROR: printer offline
>     % bdiff log1 log2
>     11580a11581
>     > 15:25:42: ERROR: printer offline
>     15080d15080
>     < 17:22:59: WARNING: queue too long; waiting
>     15080a15081
>     > 17:22:59: WARNING: queue too long; waiting

Even with that wart, sometimes you can't get along without bdiff.

- JP

28.6 Choosing Sides with sdiff |  | 28.8 More Friendly diff Output