.\" Copyright (c) 1980, 1990 The Regents of the University of California.
.\" Redistribution and use in source and binary forms are permitted provided
.\" that: (1) source distributions retain this entire copyright notice and
.\" comment, and (2) distributions including binaries display the following
.\" acknowledgement: ``This product includes software developed by the
.\" University of California, Berkeley and its contributors'' in the
.\" documentation or other materials provided with the distribution and in
.\" all advertising materials mentioning features or use of this software.
.\" Neither the name of the University nor the names of its contributors may
.\" be used to endorse or promote products derived from this software without
.\" specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\" @(#)diff.1 6.6 (Berkeley) 7/24/90
.Nd differential file and directory comparator
utility compares the contents of
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):
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
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.
are marked with `\(mi '; those added to
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 usually much easier to interpret.)
produces output in a form suitable as input for the editor utility,
which can then be used to convert file1 into file2.
Extra commands are added to the output when comparing directories with
script for converting text files which are common to the two directories
flag, but in reverse order. It cannot
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
produces a script similar to that of
but in the opposite order and with a count of changed lines on each
insert or delete command. This is the form used by
creates a merged version of
on the standard output, with C preprocessor controls included so that
a compilation of the result without defining
causes trailing blanks (spaces and tabs) to be ignored, and other
strings of blanks to compare equal.
ignores the case of letters. E.g., ``A'' will compare equal to ``a''.
will expand tabs in output lines. Normal or
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
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:
long output format; each text file
other differences are remembered and summarized
after all text file differences are reported.
recursively to common subdirectories encountered.
to report files which are the same, which are otherwise not mentioned.
in the middle beginning with file
If both arguments are directories,
sorts the contents of the directories by name, and then runs the
algorithm, producing a change list,
on text files which are different.
Binary files which differ,
common subdirectories, and files which appear in only one directory
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.
output contains lines of these forms, where
are line numbers respective of file order.
Same as above, but append the range of lines,
tells to which line the change
Delete the range of lines
Replace the range of specified lines with the line
The line numbers before the action letters pertain to
and reading the line in reverse order, one can also
pairs (where num1 = num2) are abbreviated as a single
If the environment variable
will use the name specified by
as an alternate temporary directory.
Alternate algorithm version (used by option
appeared in Version 6 AT&T Unix.
utility exits with one of the following values:
No differences were found.
do not provide special handling for lines on which the
first and only character is
This can cause problems for
When comparing directories with the
first compares the files ala
and then decides to run the
algorithm 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.