- publishing free software manuals
Comparing and Merging Files with GNU diff and patch
by David MacKenzie, Paul Eggert, and Richard Stallman
Paperback (6"x9"), 120 pages
ISBN 0954161750
RRP £12.95 ($19.95)

"Well packaged... the quality of information is excellent" --- Linux User and Developer Magazine (Issue 36, Feb 2004) Get a printed copy>>>

13 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.

ISBN 0954161750Comparing and Merging Files with GNU diff and patchSee the print edition