.\" Copyright (c) 1980 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)diff.1 6.4 (Berkeley) 5/19/86
.TH DIFF 1 "May 19, 1986"
diff \- differential file and directory comparator
If both arguments are directories,
sorts the contents of the directories by name, and then runs the
algorithm (described below)
on text files which are different.
Binary files which differ,
common subdirectories, and files which appear in only one directory
Options when comparing directories are:
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
When run on regular files, and when comparing text files which differ
during directory comparison,
tells what lines must be changed in the files to bring them into agreement.
Except in rare circumstances,
finds a smallest sufficient set of file differences.
is a directory, then either
may be given as `\-', in which case the standard input is used.
then a file in that directory whose file-name is the same as the file-name of
is used (and vice versa).
There are several options for output format;
the default output format contains lines of these forms:
The numbers after the letters pertain to
In fact, by exchanging `a' for `d' and reading backward
one may ascertain equally how to convert
are abbreviated as a single number.
Following each of these lines come all the lines that are
affected in the first file flagged by `<',
then all the lines that are affected in the second file
\fB\-b, -w, -i\fP or \fB-t\fP
which may be given with any of the others,
the following options are mutually exclusive:
the following shell program may help maintain
multiple versions of a file.
Only an ancestral file ($1) and a chain of
scripts ($2,$3,...) made by
A `latest version' appears on
\ \ \ \ \ \ \ \ (shift; cat $*; echo \'1,$p\') \(bv ed \- $1
Extra commands are added to the output when comparing directories with
script for converting text files which are common to the two directories
produces a script similar to that of
and in the opposite order.
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
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.)
does a fast, half-hearted job.
It works only when changed stretches are short
but does work on files of unlimited length.
to create a merged version of
on the standard output, with C preprocessor controls included so that
a compilation of the result without defining \fIstring\fR is equivalent
causes trailing blanks (spaces and tabs) to be ignored, and other
strings of blanks to compare equal.
but causes whitespace (blanks and tabs) to be totally ignored. E.g.,
``if\ (\ a\ ==\ b\ )'' will compare equal to ``if(a==b)''.
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
/bin/diff for directory diffs
cmp(1), cc(1), comm(1), ed(1), diff3(1)
Exit status is 0 for no differences, 1 for some, 2 for trouble.
Editing scripts produced under the
.BR \-f " option are naive about"
creating lines consisting of a single `\fB.\fR'.
When comparing directories with the
\fB\-b, -w\fP or \fB-i\fP
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 blank string or case differences.