4.3BSD-Reno/share/man/cat1/diffh.0
DIFF(1) UNIX 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] _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
into 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 out-
put 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 with `! '. Changes which lie within <context> lines of
each other are grouped together on output. (This is a change
from the previous ``diff -c'' but the resulting output is usu-
ally much easier to interpret.)
--ee produces output in a form suitable as input for the editor
utility, ed(1), which can then be used to convert file1 into
file2.
Extra commands are added to the output when comparing direc-
tories with --ee, so that the result is a sh(1) script for con-
verting 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 of the --ee flag, but in reverse order. It can-
not 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
order 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
output, with C preprocessor controls included so that a compi-
lation 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
character(s) to the front of each line which may screw up the
indentation 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 oth-
erwise 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 the _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
order.
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,_Y_Y from _f_i_l_e_1 with the
range _Z_Z,_Q_Q 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 single
number.
EENNVVIIRROONNMMEENNTT
TMPDIR If the environment variable TMPDIR exists, DDiiffff will use the
name specified by TMPDIR as an alternate temporary directory.
FFIILLEESS
/_t_m_p/_d?????
/_u_s_r/_b_i_n/_d_i_f_f_h Alternate algorithm version (used by option --hh).
/_u_s_r/_b_i_n/_d_i_f_f for directory diffs
/_u_s_r/_b_i_n/_p_r used by the --ll option.
SSEEEE AALLSSOO
cmp(1), cc(1), comm(1), ed(1), diff3(1)
HHIISSTTOORRYY
DDiiffff appeared in Version 6 AT&T Unix.
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
differences are insignificant white space or case differences.