diff – differential file comparator
file1 ... file2
tells what lines must be changed in two files to bring them
If one file
is a directory,
then a file in that directory with basename the same as that of
the other file is used.
If both files are directories, similarly named files in the
two directories are compared by the method of
If more than two file names are given, then each argument is compared
to the last argument as above.
to process similarly named subdirectories recursively.
When processing more than one file,
prefixes file differences with a single line
listing the two differing files, in the form of
flag causes this behavior even when processing single files.
The normal output contains lines of these forms:
These lines resemble
commands to convert
The numbers after the letters pertain to
In fact, by exchanging ‘a’ for ‘d’ and reading backward
one may ascertain equally how to convert
identical pairs where
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
flagged by ‘>’.
trailing blanks (spaces and tabs) to be ignored
and other strings of blanks to compare equal.
option causes all white-space to be removed from input lines
before applying the difference algorithm.
option prefixes each range with
and inserts a space around the
option produces a script of
commands for the editor
which will recreate
option produces a similar script,
not useful with
in the opposite order. It may, however, be
useful as input to a stream-oriented post-processor.
option includes three lines of context around each
change, merging changes whose contexts overlap.
In this mode,
because the former are easier to distinguish when mixed.
flag displays the entire file as context.
option provides a unix-compatible unified diff.
This format is similar to that provided by
prefixes are not separated from the rest of the line by spaces,
and the file header is in the following format:
@@ -line,len +line,len @@
Except in rare circumstances,
finds a smallest sufficient set of file
Exit status is the empty string
for no differences,
Editing scripts produced under the
-f option are naive about
creating lines consisting of a single ‘.’.
on directories, the notion of what is a text
file is open to debate.