DIFF3(1V) — USER COMMANDS
NAME
diff3 − 3-way differential file comparison
SYNOPSIS
diff3 [ −exEX3 ] file1 file2 file3
SYSTEM V SYNOPSIS
/usr/5bin/diff3 [ −ex3 ] file1 file2 file3
DESCRIPTION
diff3 compares three versions of a file, and publishes disagreeing ranges of text flagged with these codes:
==== all three files differ
====1 file1 is different
====2 file2 is different
====3 file3 is different
The types of differences between a given range within the given files is 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 file2 and file3 into file1. 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 file2 and file3, i.e. 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 file2 and file3, but treat overlapping changes (i.e., 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 file1 and file2. Applying the edit script generated by the command
diff3 -E file1 file2 file3
to file1 results in the file:
lines 1-6
of file1
<<<<<<< file1
lines 7-8
of file1
=======
lines 7-8
of file3
>>>>>>> file3
rest of file1
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 file2 and file3 into file1, and print the resulting file to the standard output. If the System V version of diff3, is used, file1 will be replaced with the resulting file.
(diff3 -e file1 file2 file3; echo ´1,$p´) │ ed − file1
FILES
/tmp/d3?????
/usr/lib/diff3
/usr/5lib/diff3prog
SEE ALSO
BUGS
Text lines that consist of a single . will defeat −e.
Sun Release 3.2 — Last change: 17 July 1986