.\" 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.1 (Berkeley) %G%
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
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 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 `!'.
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.
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
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 differences.