[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Commands Reference, Volume 2

diff3 Command


Compares three files.


diff3 -e -x -E -X -3 ] File1 File2 File3


The diff3 command compares three files and writes to standard output the ranges of text that differ, flagged with the following codes:

==== All three files differ.
====1 File1 differs.
====2 File2 differs.
====3 File3 differs.

The type of change needed to convert a given range of a given file to match another file is indicated in one of these two ways in the output:

File:Number1 a Text is to be added after line number Number1 in File, where File is 12, or 3.
                          Text in the range line Number1 to line Number2 is to be changed. If Number1 is the same as Number2, the range may be abbreviated to Number1.

The contents of the range follows a c indication. When the contents of two files are identical, the diff3 command does not show the contents of the lower-numbered file, although it shows the location of the identical lines for each.

Note: Edit scripts produced by the -e flag cannot create lines consisting of a . (period).


-3 Produces an edit script to incorporate only changes flagged ====3.
-E, -X These are similar to -e and -x respectively, but treat overlapping changes (that is, changes that would be flagged ==== in the normal listing) differently. The overlapping lines from both files are inserted by the edit script, bracketed by <<<<<< and >>>>>> lines. The -E option is used by Revision Control System (RCS) Merge to ensure that overlapping changes in the merged files are preserved and brought to someone's attention.
-e Creates an edit script for use with the ed command to incorporate into File1 all changes between File2 and File3 (that is, the changes that normally would be flagged ==== and ====3).
-x Produces an edit script to incorporate only changes flagged ====.


To list the differences among three files:

diff3 fruit.a fruit.b fruit.c

If fruit.a , fruit.b , and fruit.c contain the following data:

fruit.a         fruit.b         fruit.c
banana          apple           grape
grape           banana          grapefruit
kiwi            grapefruit      kiwi
lemon           kiwi            lemon
mango           orange          mango
orange          peach           orange
peach           pear            peach

then the output from the diff3 command shows the differences between these files as follows. (The comments on the right do not appear in the output.)

====            All three files are different.
1:1,2c          Lines 1 and 2 of the first file, fruit.a
2:1,3c          Lines 1 through 3 of fruit.b
3:1,2c          Lines 1 and 2 of fruit.c
====2           The second file, fruit.b, is different.
1:4,5c          Lines 4 and 5 the same in fruit.a and fruit.c.
2:4a            To make fruit.b look same, add after line 4.
====            The first file, fruit.a, is different.
2:7c            fruit.b line 7 and fruit.c line 8 are the same


/usr/bin/diff3 Indicates the diff3 command.
/usr/lbin/diff3prog Called by the diff3 shell script.

Related Information

The diff command, ed command.

Files Overview in AIX Version 4.3 System User's Guide: Operating System and Devices introduces you to files and the way you can work with them.

Input and Output Redirection Overview in AIX Version 4.3 System User's Guide: Operating System and Devices describes how the AIX operating system processes input and output.

[ Previous | Next | Contents | Glossary | Home | Search ]