diff.1 (2010 09)

d
diff(1) diff(1)
within 3 lines of each other in the file are grouped together on output.
-C n Output format similar to -c but with n lines of context.
-h Do a fast, half-hearted job. This option works only when changed stretches are short and
well separated, but can be used on files of unlimited length.
-D string
Create a merged version of file1 and file2 on the standard output, with C preprocessor con-
trols included so that a compilation of the result without defining string is equivalent to
compiling file1, while compiling the result with string defined is equivalent to compiling
file2.
-b Ignore trailing white space characters, except newline character and treat other string
of blanks as equal. For example,
xyz\t\f and xyz are treated as equal.
-w Ignore all white space characters, except newline character. For example,
if(a==
b)and if(a==b) are treated as equal.
-i Ignores uppercase/lowercase differences. Thus
A is treated the same as a.
-t Expand tabs in output lines. Normal or
-c output adds one or more characters to the
front of each line. Resulting misalignment of indentation in the original source lines can
make the output listing difficult to interpret. This option preserves original source file
indentation.
EXTERNAL INFLUENCES
Environment Variables
LANG determines the locale to use for the locale categories when both LC_ALL and the corresponding
environment variable (beginning with LC_) do not specify a locale. If LANG is not set or is set to the
empty string, a default of "C" (see lang (5)) is used.
LC_CTYPE determines the space characters for the diff command, and the interpretation of text
within file as single- and/or multi-byte characters.
LC_MESSAGES determines the language in which messages are displayed.
If any internationalization variable contains an invalid setting,
diff and diffh behave as if all inter-
nationalization variables are set to "C". See environ (5).
International Code Set Support
Single- and multi-byte character code sets are supported with the exception that
diff and diffh do
not recognize multi-byte alternative space characters.
RETURN VALUE
Upon completion,
diff returns with one of the following exit values:
0 No differences were found.
1 Differences were found.
>1 An error occurred.
EXAMPLES
The following command creates a script file
script:
diff -e x1 x2 >script
w is added to the end of the script in order to save the file:
echo w >> script
The script file can then be used to create the file x2 from the file x1 using the editor ed in the following
manner:
ed x1 < script
The following command produces the difference output with 2 lines of context information before and
after the line that was different:
diff -C2 x1 x2
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010