COHERENT manpages
This page displays the COHERENT manpage for diff [Compare two files].
List of available manpages
Index
diff -- Command
Compare two files
diff [-bdefh] [-c symbol] file1 file2
diff compares file1 with file2, and prints a summary of the changes needed
to turn file1 into file2.
Two options involve input file specification. First, the standard input
may be specified in place of a file by entering a hyphen `-' in place of
file1 or file2. Second, if file1 is a directory, diff looks within that
directory for a file that has the same name as file2, then compares file2
with the file of the same name in directory file1.
The default output script has lines in the following format:
1,2 c 3,4
The numbers 1,2 refer to line ranges in file1, and 3,4 to ranges in file2.
The range is abbreviated to a single number if the first number is the same
as the second. The command c was chosen from among the ed commands `a',
`c', and `d'. diff then prints the text from each of the two files. Text
associated with file1 is preceded by `< ', whereas text associated with
file2 is preceded by `>'.
The following summarizes diff's options.
-b Ignore trailing blanks and treat more than one blank in an input line as
a single blank. Spaces and tabs are considered to be blanks for this
comparison.
-c symbol
Produce output suitable for the C preprocessor cpp; the output contains
#ifdef, #ifndef, #else, and #endif lines. symbol is the string used to
build the #ifdef statements. If you define symbol to the C preprocessor
cpp, it will produce file2 as its output; otherwise, it will produce
file1. This option does not work for files that already contain #ifdef,
#ifndef, #else, and #endif statements.
-e Create an ed script that will convert file1 into file2.
-f Produce a script in the same manner as the -e option, but with line
numbers taken directly from the two input files. This will work
properly only if applied from end to beginning; it cannot be used
directly by ed.
-h Compare large files that have a minimal number of differences. This
option uses an algorithm that is not limited by file length, but may not
discover all differences.
-d Select the -h algorithm only for files larger than 25,000 bytes;
otherwise, use the normal algorithm.
Example
For an example of a script that uses this command, see the Lexicon entry
for trap.
See Also
ed,
egrep,
commands,
zdiff
Diagnostics
diff's exit status is zero when the files are identical, one when they are
different, and two if a problem was encountered (e.g., could not open a
file).
Notes
diff cannot handle files with more than 32,000 lines. Handing diff a file
that exceeds that limit will cause it to fail, with unpredictable side
effects.