Linux bdiff command

Updated: 11/06/2021 by Computer Hope
bdiff command

On Unix-like operating systems, the bdiff command calculates and reports the diffs for two big files.

Note

Bdiff is a Unix heirloom (legacy) command, and may not be available for installation by your operating system's package manager.

Description

The bdiff command compares the files specified by the filename1 and filename2 parameters and writes information about their differing lines to standard output. If either file name is - (a single dash), bdiff reads from standard input. The bdiff command is used like the diff command to find lines that must be changed in two files to make them identical. Some files are too large for diff to process, however, and that's where bdiff can be used.

bdiff ignores lines common to the beginning of both files, splits the remainder of each file into segments of number lines each, and then tells diff to compare the corresponding segments. By default, the number parameter is 3500 lines. In some cases, even 3500 lines at a time is too large for diff to work with; if diff fails, try using a smaller value for number.

Output of bdiff has the same format as normal diff output, except bdiff line numbers are adjusted to account for the segmenting of the files. It should be noted that because the files are segmented, bdiff does not necessarily find the smallest possible set of file differences.

Syntax

bdiff { filename1 | - } { filename2 | - } [ number ] [ -s ]

Options

filename1 Name of first file to compare.
filename2 Name of second file to compare.
number Specifies the number of lines each file should be segmented into. The value of number is 3500 by default.
-s Tells bdiff to be silent (no diagnostic output). However, this does not suppress possible diagnostic messages from diff itself.

Examples

bdiff myfile1.txt myfile2.txt

Compare the files myfile1.txt and myfile2.txt. Results will be formatted similar to the following output:

1c1
< is this ln
---
> test
3,5d2
< Hello world
< this is a test
< of the bdiff file

diff — Identify the differences between two files.