Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)
User Commands (d - f) diff(1)
NAME
diff - Compares text files
SYNOPSIS
diff [-c | -C number | -e | -f | -n][-br] directory1 directory2
diff [-c | -C number | -e | -f | -n][-b] file1 file2
FLAGS
The -c, -C, -e, -f, and -n flags are mutually exclusive.
The -r flag can be specified only with directory comparisons.
The -b flag can be used in combination with any other flags and in both file 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 files being compared and their last modification dates, then lists the differing lines.
Lines that are changed from one file to the other are marked in both files with an ! (exc-
lamation point). Changes that lie within the specified number of lines of each other are
grouped together on output.
-C number
Produces output that provides the number of lines of context specified 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 file2
from file1. In connection with -e, the following shell program can help maintain multi-
ple versions of a file. Only an ancestral file ($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 files 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 files in common subdirectories recursively.
DESCRIPTION
Input Options
If neither the file1 nor the file2 argument is a directory, then either can be given as - (dash), in
which case the standard input is used. If file1 is a directory and file2 is a file, or vice versa, a file
in the specified directory with the same name as the specified file is used.
If both arguments are directories, the diff command sorts the contents of the directories by name,
and then runs the regular diff file algorithm on text files that are different. Binary files that differ,
common subdirectories, and files that appear in only one directory are also listed.
527188-004 Hewlett-Packard Company 3−11