Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)

User Commands (d - f) diff(1)
NAME
diff - Compares text les
SYNOPSIS
diff [-c | -C number | -e | -f | -n][-br] directory1 directory2
diff [-c | -C number | -e | -f | -n][-b] le1 le2
FLAGS
The -c, -C, -e, -f, and -n ags are mutually exclusive.
The -r ag can be specied only with directory comparisons.
The -b ag can be used in combination with any other ags and in both le and directory com-
parisons.
-b Causes trailing spaces and tabs (blanks) to be ignored, and other strings of spaces and
tabs to be considered to be identical.
-c Produces a listing with the default number of lines of context (3 lines). The output lists
the les being compared and their last modication dates, then lists the differing lines.
Lines that are changed from one le to the other are marked in both les with an ! (exc-
lamation point). Changes that lie within the specied number of lines of each other are
grouped together on output.
-C number
Produces output that provides the number of lines of context specied by the number
argument (where number is a positive decimal integer).
-e Produces a script of a, c, d, and s commands for the editor ed, which can re-create le2
from le1. In connection with -e, the following shell program can help maintain multi-
ple versions of a le. Only an ancestral le ($1) and a chain of version-to-version ed
scripts ($2, $3, ...) made by the diff command need be on hand. A "latest version"
appears on the standard output, as shown below:
(shift; cat $*; echo ’1,$p’) | ed - $1
Extra commands are added to the output when comparing directories with -e; the result
is an sh script for converting text les common to the directories from their state in
directory1 to their state in directory2.
-f Produces a script similar to that of -e, but not useful with the ed editor, and in the oppo-
site order.
-r Checks les in common subdirectories recursively.
DESCRIPTION
Input Options
If neither the le1 nor the le2 argument is a directory, then either can be given as - (dash), in
which case the standard input is used. If le1 is a directory and le2 is a le, or vice versa, a le
in the specied directory with the same name as the specied le is used.
If both arguments are directories, the diff command sorts the contents of the directories by name,
and then runs the regular diff le algorithm on text les that are different. Binary les that differ,
common subdirectories, and les that appear in only one directory are also listed.
527188-004 Hewlett-Packard Company 311