diff3(1) diff3(1)
NAME
diff3 - three-way differential file comparator
SYNOPSIS
diff3 [option ...] file1 file2 file3
DESCRIPTION
diff3 compares three files, outputs the ranges of lines in which they
differ to standard output, and indicates what changes need to be made
to make them identical.
OPTIONS
No option specified:
In the case of line ranges that do not match, diff3 flags the
ranges of text with the following codes:
==== all 3 files differ
====1 file1 differs from file2 and file3
====2 file2 differs from file1 and file3
====3 file3 differs from file1 and file2
This flag is followed by the changes that have to be made in
order to convert a given range in one file to a given range in
some other file. Such changes are output in one of the following
two formats:
Change text:
f:n1[,n2]c
[text]
To eliminate the differences, line n1 or the range n1 to n2 must
be changed (c) in file f (where f = 1, 2, or 3). text is the ori-
ginal contents of the line range to be changed. If the contents
of two files do not differ in the given range, text will not be
displayed for the file with the lower f number.
Append text:
f:na
[text]
To eliminate the differences, text must be appended (a) after
line n in file f (where f = 1, 2, or 3). text is the line range
to be appended. If the contents of two files do not differ in the
given range, text will not be displayed for the file with the
lower f number.
Page 1 Reliant UNIX 5.44 Printed 11/98
diff3(1) diff3(1)
OPTIONS
-e diff3 produces an ed script which will incorporate into file1 all
changes between file2 and file3, i.e. the changes that would be
flagged ==== or ====3 if no option were specified [see ed(1)].
Caution:
The -e option is ignored in the case of text lines that con-
sist of nothing but a single period (.).
Examples:
Contents of file1 file2 file3
maybe surely maybe
tomorrow today today
Calling diff3 -e generates the following output:
$ diff3 -e file1 file2 file3
1,2c
maybe
today
.
w
q
Contents of file1 file2 file3
maybe maybe maybe
today
tomorrow
Calling diff3 -e generates the following output:
$ diff3 -e file1 file2 file3
1a
today
tomorrow
.
w
q
-E diff3 produces an ed script which will incorporate into file1 all
changes between file2 and file3, i.e. the changes that would be
flagged ==== or ====3 if no option were specified [see ed(1)].
In this case, however, diff3 will expand the output in the ed
script for changes that would be flagged ==== if no option were
specified. These changes are enclosed within <<<<<< or >>>>>>
lines, depending on the file where they are located.
Page 2 Reliant UNIX 5.44 Printed 11/98
diff3(1) diff3(1)
-x diff3 produces an ed script which will incorporate into file1
only those changes between file2 and file3 that would be flagged
==== if no option were specified [see ed(1)].
-X diff3 produces an expanded ed script which will incorporate into
file1 only those changes between file2 and file3 that would be
flagged ==== if no option were specified [see ed(1)].
These changes are enclosed within <<<<<< or >>>>>> lines, depend-
ing on the file where they are located.
-3 diff3 produces an ed script which will incorporate into file1
only those changes between file2 and file3 that would be flagged
====3 if no option were specified [see ed(1)].
file1 file2 file3
Names of the three files that you want to compare.
diff3 will find a maximum of 200 differences between the three
files.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed. If LCMESSAGES is undefined or is defined
as the null string, it defaults to the value of LANG. If LANG is like-
wise undefined or null, the system acts as if it were not internation-
alized.
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization.
EXAMPLES
You have three versions of an address file, called adr1, adr2 and
adr3. The contents of these files are shown below:
Contents of adr1: Contents of adr2: Contents of adr3:
Mervyn Parry Mervyn Parry Mervyn Parry
3 Kings Rd. 3 Kings Rd. 3 Kings Rd.
London W5 London W5 London W5
Tel.: 01-987654 Tel.: 01-987654 Tel.: 01-987654
Saul Mahoney Saul Mahoney Saul Mahoney
83 Charles St 83 Charles St 83 Charles St
Baltimore, USA Baltimore, USA Baltimore, USA
Tel.: 747 1510 Tel.: 747 1450 Tel.: 747 1450
Page 3 Reliant UNIX 5.44 Printed 11/98
diff3(1) diff3(1)
Robert Jeffery
4 Grosvenor Rd
Acton W3
01-777888
Example 1
Calling diff3 without options:
$ diff3 adr1 adr2 adr3
====
1:9c
Tel.: 747 1510
2:9c
Tel.: 747 1450
3:9,14c
Tel.: 747 1450
Robert Jeffery
4 Grosvenor Rd
Acton W3
01-777888
Example 2
Calling diff3 with option -e:
$ diff3 -e adr1 adr2 adr3
9c
Tel.: 747 1450
Robert Jeffery
4 Grosvenor Rd
Acton W3
01-777888
.
w
q
If you redirect the output of diff3 -e to a file named script, you can
incorporate the changes in adr1 with the following command line:
$ (cat script; echo '1,$p') | ed - adr1
Page 4 Reliant UNIX 5.44 Printed 11/98
diff3(1) diff3(1)
Example 3
Calling diff3 with option -3:
$ diff3 -3 adr1 adr2 adr3
This call does not generate any output, since adr1 and adr2 are not
identical. diff3 -3 produces an ed script only when there are changes
of type ====3; all differences in this example are of the ==== type.
FILES
/tmp/d3a*
File created by diff containing the differences between file1 and
file3. diff is called by diff3.
/tmp/d3b*
File created by diff containing the differences between file2 and
file3.
/usr/lib/diff3prog
Program called by diff3 to compare the files /tmp/d3a* and
/tmp/d3b*.
SEE ALSO
diff(1), ed(1).
Page 5 Reliant UNIX 5.44 Printed 11/98