4.4BSD/usr/share/man/cat1/diffh.0
DIFF(1) BSD Reference Manual DIFF(1)
NNAAMMEE
ddiiffff - differential file and directory comparator
SSYYNNOOPPSSIISS
ddiiffff [--cceeffhhnn] [--bbiiwwtt] _f_i_l_e_1 _f_i_l_e_2
ddiiffff [--DD_s_t_r_i_n_g] [--bbiiww] _f_i_l_e_1 _f_i_l_e_2
ddiiffff [--ll] [--rr] [--ss] [--cceeffhhnn] [--bbiiwwtt] [--SS_n_a_m_e] _d_i_r_1 _d_i_r_2
DDEESSCCRRIIPPTTIIOONN
The ddiiffff utility compares the contents of _f_i_l_e_1 and _f_i_l_e_2 and writes to
the standard output the list of changes necessary to convert one file in-
to the other. No output is produced if the files are identical.
Output options (mutually exclusive):
--cc produces a diff with lines of context. The default is to present
3 lines of context and may be changed, e.g., to 10, by --cc1100. With
--cc the output format is modified slightly: the output beginning
with identification of the files involved and their creation
dates and then each change is separated by a line with a dozen
*'s. The lines removed from _f_i_l_e_1 are marked with `- '; those
added to _f_i_l_e_2 are marked `+ '. Lines which are changed from one
file to the other are marked in both files with `! '. Changes
which lie within <context> lines of each other are grouped to-
gether on output. (This is a change from the previous ``diff
-c'' but the resulting output is usually much easier to inter-
pret.)
--ee produces output in a form suitable as input for the editor utili-
ty, ed(1), which can then be used to convert file1 into file2.
Extra commands are added to the output when comparing directories
with --ee, so that the result is a sh(1) script for converting text
files which are common to the two directories from their state in
_d_i_r_1 to their state in _d_i_r_2.
--ff identical output to that of the --ee flag, but in reverse order.
It cannot be digested by ed(1).
--hh Invokes an alternate algorithm which can handle files of very
long lengths. There is a trade off. The algorithm can only deal
with changes which are clearly delimited and brief. Long sections
of changes and overlaps will confuse it.
--nn produces a script similar to that of --ee, but in the opposite or-
der and with a count of changed lines on each insert or delete
command. This is the form used by rcsdiff(1).
--DD_s_t_r_i_n_g
creates a merged version of _f_i_l_e_1 and _f_i_l_e_2 on the standard out-
put, with C preprocessor controls included so that a compilation
of the result without defining _s_t_r_i_n_g is equivalent to compiling
_f_i_l_e_1, while defining _s_t_r_i_n_g will yield _f_i_l_e_2.
Comparison options:
--bb causes trailing blanks (spaces and tabs) to be ignored, and other
strings of blanks to compare equal.
--ii ignores the case of letters. E.g., ``A'' will compare equal to
``a''.
--tt will expand tabs in output lines. Normal or --cc output adds char-
acter(s) to the front of each line which may screw up the inden-
tation of the original source lines and make the output listing
difficult to interpret. This option will preserve the original
source's indentation.
--ww is similar to --bb but causes whitespace (blanks and tabs) to be
totally ignored. E.g., ``if ( a == b )'' will compare equal to
``if(a==b)''.
Directory comparison options:
--ll long output format; each text file ddiiffff'd is piped through pr(1)
to paginate it, other differences are remembered and summarized
after all text file differences are reported.
--rr causes application of ddiiffff recursively to common subdirectories
encountered.
--ss causes ddiiffff to report files which are the same, which are other-
wise not mentioned.
--SS_n_a_m_e re-starts a directory ddiiffff in the middle beginning with file
_n_a_m_e.
If both arguments are directories, ddiiffff sorts the contents of the direc-
tories by name, and then runs the regular file ddiiffff algorithm, producing
a change list, on text files which are different. Binary files which
differ, common subdirectories, and files which appear in only one direc-
tory are described as such.
If only one of _f_i_l_e_1 and _f_i_l_e_2 is a directory, ddiiffff is applied to the
non-directory file and the file contained in the directory file with a
filename that is the same as the last component of the non-directory
file.
If either _f_i_l_e_1 or _f_i_l_e_2 is `--', the standard input is used in its place.
OOuuttppuutt SSttyyllee
The default (without --ee, --cc, or --nn options) output contains lines of
these forms, where _X_X, _Y_Y, _Z_Z, _Q_Q are line numbers respective of file or-
der.
XXaaYY At (the end of) line _X_X of _f_i_l_e_1, append the contents of
line _Y_Y of _f_i_l_e_2 to make them equal.
XXaaYY,ZZ Same as above, but append the range of lines, _Y_Y through _Z_Z
of _f_i_l_e_2 to line _X_X of file1.
XXddYY At line _X_X delete the line. The value _Y_Y tells to which line
the change would bring _f_i_l_e_1 in line with _f_i_l_e_1.
XX,YYddZZ Delete the range of lines _X_X through _Y_Y in _f_i_l_e_1.
XXccYY Change the line _X_X in _f_i_l_e_1 to the line _Y_Y in _f_i_l_e_2_.
XX,YYccZZ Replace the range of specified lines with the line _Z_Z.
XX,YYccZZ,QQ Replace the range _X_X,YY from _f_i_l_e_1 with the range _Z_Z,QQ from
_f_i_l_e_2.
These lines resemble ed(1) subcommands to convert _f_i_l_e_1 into _f_i_l_e_2. The
line numbers before the action letters pertain to _f_i_l_e_1; those after per-
tain to _f_i_l_e_2. Thus, by exchanging aa for dd and reading the line in re-
verse order, one can also determine how to convert _f_i_l_e_2 into _f_i_l_e_1. As
in ed(1), identical pairs (where num1 = num2) are abbreviated as a sin-
gle number.
EENNVVIIRROONNMMEENNTT
TMPDIR If the environment variable TMPDIR exists, ddiiffff will use the di-
rectory specified by TMPDIR as the temporary directory.
FFIILLEESS
/tmp/d?????
/usr/bin/diffh Alternate algorithm version (used by option --hh).
/usr/bin/diff for directory diffs
/usr/bin/pr used by the --ll option.
SSEEEE AALLSSOO
cmp(1), cc(1), comm(1), ed(1), diff3(1)
DDIIAAGGNNOOSSTTIICCSS
The ddiiffff utility exits with one of the following values:
0 No differences were found.
1 Differences were found.
>1 An error occurred.
BBUUGGSS
The --ff and --ee options do not provide special handling for lines on which
the first and only character is ``.''. This can cause problems for ed(1).
When comparing directories with the --bb, --ww or --ii options specified, ddiiffff
first compares the files ala _c_m_p, and then decides to run the ddiiffff algo-
rithm 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 dif-
ferences are insignificant white space or case differences.
HHIISSTTOORRYY
A ddiiffff command appeared in Version 6 AT&T UNIX.
4th Berkeley Distribution June 30, 1993 3