diffbin does a byte-by-byte "diff" of two files which are not lines of text.
$ diffbin myoldfile mynewfile $ diffbin -context=20 myoldfile mynewfile $ diffbin -context=20 -matchsize=20 -hexpos -ascii myoldfile mynewfile
diffbin does a byte-by-byte "diff" of two files which are not lines of text. For example, you could compare two executables and see the extra 7 bytes that are in one.
The output is in hexadecimal, showing you bytes that get added to and deleted from the "old" file to make the "new" file.
There is no known program analogous to patch that takes the output of diffbin and creates a copy of the new file from a copy of the old file. But there are several alternatives to diffbin listed on Freshmeat that are specifically designed to create such a patch file. These alternatives do not, however, produce output as useful as diffbin's for analyzing the difference between two files.
- 25: 6c7564 + 67: 65787472 61737475 666620 - 153: 74696d65 73 + 161: 67617262 616765
It says:
Here's an example with context. We used the option --context=4 on the same old and new files as the previous example.
21: 23696e63 - 25: 6c7564 28: 65203c73 66: 75646520 + 67: 65787472 61737475 666620 70: 3c737464 149: 7379732f - 153: 74696d65 73 + 161: 67617262 616765 158: 2e683e0a
You see that diffbin has added lines showing 4 bytes on either side of each difference which are the same in both the old and the new files. For these common bytes, the offset is that in the old file. You have to figure out for yourself where the same bytes are in the new file.
The offset value on a deleted or same line (minus sign or no sign) is the offset in the old file. The offset value on an added line (plus sign) is the offset in the new file.
To avoid confusion in reading the offsets, just pretend the offsets with a plus sign before them aren't there. Then you have a simple picture of the old file, with new bytes stuck in between old ones.
The two arguments identify the two files to compare. We arbitrarily call the first file the "old" file and the second one the "new file." you get the same comparison regardless of the order in which you specify the files. But if you think of one file as a modification to the other, you can save yourself some confusion reading this manual and the diffbin output by making that the "new" file.
The simplest way to specify the files is just to give file names for both. They can be absolute or relative file names (starting with slash or not).
Alternatively, for the new file, you can specify just the directory part of the file name and diffbin will assume the same final component os the old file. (For example, you specify /usr/src/oldprog/foo.c for the old file and /usr/src/newprog for the new file. That means the new file is /usr/src/newprog/foo.c.
The default is 16.
diffbin works by dividing the files into areas where the files match, areas where one file has stuff that is missing from the other, and areas where the two files have different contents.
The default is 8.
The default is 0.
You can't specify both -context and -all.
This option says to include all of the contents of both files in the output -- the differing and nondiffering parts alike. It's like -context with infinity as the value.
You can't specify both -context and -all.
Pedantic terminology note: Some people say the top line is hexadecimal and the bottom line is ASCII. This is wrong. The top line is ASCII (in hexadecimal) and the bottom line is standard typographical text.