diff(1) CLIX diff(1)
NAME
diff - Runs a differential file comparator
SYNOPSIS
diff [-efbh] file1 file2
FLAGS
-b Causes trailing blanks (spaces and tabs) to be ignored and other
strings of blanks to compare equal.
-e Produces a script of a, c, and d commands for the editor ed, which
will recreate file2 from file1.
-f Produces a script similar to the -e flag, in the opposite order.
This script is not useful with ed. In connection with -e, the
following shell program may help maintain multiple versions of a
file. Only an ancestral file ($1) and a chain of version-to-version
ed scripts ($2, $3, ... ) made by diff need be on hand. A ``latest
version'' appears on stdout.
(shift; cat $*; echo '1,$p')|ed - $1
Except in rare circumstances, diff finds a smallest sufficient set of
file differences.
-h Performs a fast comparison. This flag works only when changed
stretches are short and well separated, but it works on files of
unlimited length. The -e and -f are unavailable with -h.
DESCRIPTION
The diff command tells what lines must be changed in two files to bring
them into agreement. If file1 (file2) is -, stdin is used. If file1
(file2) is a directory, then a file in that directory with the name file2
(file1) is used. The normal output contains lines of these forms:
nl a n3, n4
n1,n2 d n3
n1,n2 c n3,n4
These lines resemble ed commands to convert file1 into file2. The numbers
after the letters pertain to file2. In fact, by exchanging a for d and
reading backward one may ascertain equally how to convert file2 into
file1. As in ed, identical pairs, where n1 = n2 or n3 = n4, are
abbreviated as a single number.
Following each of these lines come all the lines that are affected in the
first file flagged by <, then all the lines that are affected in the
2/94 - Intergraph Corporation 1
diff(1) CLIX diff(1)
second file flagged by >.
EXAMPLES
Given the following two files: file1:
Oh, give me
a home
where the
buffalo roam
file2:
Oh, give me
land, lotsa land,
where the
buffalo roam
Entering the command
diff file1 file2
produces the following output:
2c2
< a home
---
> land, lotsa land,
4c4
< buffalo roam
---
> buffalo roam
The command
diff -b file1 file2
produces the following output:
2c2
< a home
---
> land, lotsa land,
Note that the last line, which differed only in spaces, is considered the
same with the -b flag.
Entering the command
diff -e file1 file2
2 Intergraph Corporation - 2/94
diff(1) CLIX diff(1)
will produce the following:
4c
buffalo roam
2c
land, lotsa land,
This output can be used as an ed script.
FILES
/tmp/d?????
/usr/lib/diffh
for -h
NOTES
Editing scripts produced under the -e or -f flag are naive about creating
lines consisting of a single dot (.).
DIAGNOSTICS
Missing newline at end of file X
Indicates that the last line of file X did not have a newline. If
the lines are different, they will be flagged and output; although
the output will seem to indicate they are the same.
diff: files too big, try -h
Indicates that the files being processed are too big for diff to
process. Using -h will work with any size file, but is less
useful.
EXIT VALUES
The exit status for diff is as follows:
0 No differences exist.
1 Some differences exist.
2 Trouble has occurred.
RELATED INFORMATION
Commands: bdiff(1), cmp(1), comm(1), ed(1)
2/94 - Intergraph Corporation 3