diff3

compare three text files 

Command


SYNOPSIS

diff3 [-bEeHhXx3] file1 file2 file3 [mark1[mark3]]


DESCRIPTION

The diff3 command compares three versions of a text file (found in file1, file2 and file3) on a line by line basis using the diff command.

diff3 marks ranges of disagreeing text lines with one of the following headers:

====1 

only file1 is different.

====2 

only file2 is different.

====3 

only file3 is different.

==== 

there are differences in all three files.

After the header, label lines of either of the following two forms may appear to show the differences that apply to each file:

f:m,nc
f:na

The label f says which of the three files is being described: 1, 2, or 3. The first label form shows a change in file f from lines m to n inclusive, with the actual text following the label line. The second form indicates that the following text is appended after line n of file f.

Options

All of the following options tell diff3 to produce an editing script instead of the output described earlier. All scripts consist of commands for the line-oriented text editor ed, that can be run on this script to make the indicated changes to file1.

-b 

ignores white space preceding the newline at the end of each line and considers strings of white space elsewhere in input lines to be equivalent. For example if one file contained a string of three spaces and a tab at a given location while the other file contained a string of two spaces at the same location, diff3 would not report this as a difference.

-E 

is similar to -e, except that it also checks for overlapping ranges of lines in the changes. diff3 highlights these ranges in the output.

-e 

produces an editor script of only those changes flagged ==== or ====3.

-H 

tells diff to use the -H option when called by diff3.

-h 

tells diff to use the -h option when called by diff3.

-X 

is similar to -x except that it also checks for overlapping ranges of lines in the changes. diff3 highlights these ranges in the output.

-x 

produces an editor script of only those changes where all three files differ.

-3 

produces an editor script containing changes that occur only in file3.

Under the -E and -X options, diff3 highlights overlapping regions as follows:

<<<<<<<< file1
lines from file1
========
lines from file3
>>>>>>>> file3

If you specify the arguments mark1 and/or mark3 on the command line, diff3 uses them as labels in this sort of highlighting instead of the names of file1 and file3.


EXAMPLES

Here are two commands that you can submit to the shell.

(diff3 -e file1 file2 file3 ; echo '1,$p') | ed -s file1

This simply prints file1 incorporating the changes between file2 and file3; but it does not save those changes.

(diff3 -e file1 file2 file3; echo 'wq') | ed -s file1

This edits file1 and saves the changes.


ENVIRONMENT VARIABLES

DIFFPATH 

specifies the full path name of the diff utility called by diff3. If not set, the diff utility found using the normal search path is called.


DIAGNOSTICS

Possible exit status values are:

0 

There were no differences among the three files.

1 

Some differences were found.

2 

Failure due to any of the following

— invalid command line argument
— wrong number of files on the command line
— cannot open the input file or temporary working file
— cannot create a temporary working file
— cannot find diff
— cannot invoke diff
— failure of diff
— unexpected end-of-file
— insufficient memory
— invalid control line
— missing or out-of-place --- difference separator
2+n 

With the options that check for overlapping differences (-E and -X), the status indicates that there were n overlapping ranges of differences; for example, a status of 3 indicates one overlap.

Messages

Cannot find "diff 

The executable file for diff is not found in any directory in the PATH environment variable. Check the setting of this variable.

"diff command failed 

For some reason, the diff command was unable to complete its task. If you receive this message, please contact technical support.

File "filename" ... 

One of the three input files was not able to be opened for reading for the reason given.

Insufficient memory 

To handle certain types of overlapping differences correctly, diff3 must sometimes allocate memory to hold these changes temporarily. This message should not happen under normal circumstances.

No temporary files available 

diff3 must store output from the diff command in a temporary working file. This message is given when this temporary file cannot be created. You should have either a /tmp directory or have set the TMPDIR environment variable to another directory that exists and has space for creating files.

Unexpected end of file 
file: Bad control line ... 
file: Expecting `---'; got ... 

diff3 operates by calling the diff command and processing the output that results. Any of these messages indicates that diff3 received unexpected output from diff. Since this should not happen, please contact technical support if you receive any of these messages.

You must specify exactly 3 input files 

This message is given if you do not specify the correct number of input files.


LIMITS

The longest input line is restricted to 1024 characters.


PORTABILITY

All UNIX systems. Windows 7. Windows Server 2008 R2. Windows 8. Windows Server 2012. Windows 10. Windows Server 2016.

The -E, -H, -h, and -X options are extensions to traditional implementations of diff3.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC Integrity


SEE ALSO

Commands:
diff, ed


PTC MKS Toolkit 10.1 patch 1 Documentation Build 2.