Node:
Invoking diff,
Next:
Invoking diff3,
Previous:
Invoking cmp,
Up:
Top
Invoking diff
The format for running the diff
command is:
diff options... files...
In the simplest case, two file names from-file and
to-file are given, and diff
compares the contents of
from-file and to-file. A file name of -
stands for
text read from the standard input. As a special case, diff - -
compares a copy of standard input to itself.
If one file is a directory and the other is not, diff
compares
the file in the directory whose name is that of the non-directory.
The non-directory file must not be -
.
If two file names are given and both are directories,
diff
compares corresponding files in both directories, in
alphabetical order; this comparison is not recursive unless the
-r
or --recursive
option is given. diff
never
compares the actual contents of a directory as if it were a file. The
file that is fully specified may not be standard input, because standard
input is nameless and the notion of "file with the same name" does not
apply.
If the --from-file=file
option is given, the number of
file names is arbitrary, and file is compared to each named file.
Similarly, if the --to-file=file
option is given, each
named file is compared to file.
diff
options begin with -
, so normally file names
may not begin with -
. However, --
as an
argument by itself treats the remaining arguments as file names even if
they begin with -
.
An exit status of 0 means no differences were found, 1 means some
differences were found, and 2 means trouble.