DIFF3(1V) — USER COMMANDS
NAME
diff3 − display line-by-line differences between 3 files
SYNOPSIS
diff3 [ −exEX3 ] filename1 filename2 filename3
SYSTEM V SYNOPSIS
/usr/5bin/diff3 [ −ex3 ] filename1 filename2 filename3
AVAILABILITY
The System V version of this command is available with the System V software installation option. Refer to Installing SunOS 4.1 for information on how to install optional software.
DESCRIPTION
diff3 compares three versions of a file, and publishes disagreeing ranges of text flagged with these codes:
==== All three files differ
====1 filename1 is different
====2 filename2 is different
====3 filename3 is different
The types of differences between a given range within the given files are indicated in one of these ways:
f:n1a Text is to be appended after line number n1 in file f, where f = 1, 2, or 3.
f:n1,n2c Text is to be changed in the range line n1 to line n2. If n1 = n2, the range may be abbreviated to n1.
The original contents of the range follows immediately after a c indication. When the contents of two files are identical, the contents of the lower-numbered file is suppressed.
OPTIONS
The options to diff3 instruct it to produce a script for the editor ed, rather than a list of differences. This script will incorporate some or all of the differences between filename2 and filename3 into filename1. This script will not include a w or q command at the end, so that it will not write out the changed file.
−e Produce a script that will incorporate all changes between filename2 and filename3, that is, the changes that normally would be flagged ‘====’ and ‘====3’.
−x Produce a script that will incorporate only changes flagged ‘====’.
−3 Produce a script that will incorporate only changes flagged ‘====3’.
−E Produce a script that will incorporate all changes between filename2 and filename3, but treat overlapping changes (that is, changes that would be flagged with ==== in the normal listing) differently. The overlapping lines from both files will be inserted by the edit script, bracketed by <<<<<< and >>>>>> lines.
−X Produce a script that will incorporate only changes flagged ====, but treat these changes in the manner of the −E option.
For example, suppose lines 7-8 are changed in both filename1 and filename2. Applying the edit script generated by the command
diff3 −E filename1 filename2 filename3
to filename1 results in the following file.
lines 1-6
of filename1
<<<<<<< filename1
lines 7-8
of filename1
=======
lines 7-8
of filename3
>>>>>>> filename3
rest of filename1
SYSTEM V OPTIONS
The System V version of diff3 does not support the −E and −X options. The script produced by the −e, −x, and −3 options does include a w and q command at the end, so that it will write out the changed file.
EXAMPLES
The following command will incorporate all the changes between filename2 and filename3 into filename1, and print the resulting file to the standard output. If the System V version of diff3, is used, filename1 will be replaced with the resulting file.
(diff3 −e filename1 filename2 filename3; echo ´1,$p´) │ ed − filename1
FILES
/tmp/d3?????
/usr/lib/diff3
/usr/5lib/diff3prog
SEE ALSO
BUGS
Text lines that consist of a single ‘.’ will defeat a −e option.
Sun Release 4.1 — Last change: 9 September 1987