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:
only file1 is different.
only file2 is different.
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:
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.
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.
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.
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.
tells diff to use the
-Hoption when called by diff3. -h
tells diff to use the
-hoption when called by diff3. -X
is similar to
-xexcept 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.
produces an editor script containing changes that occur only in file3.
<<<<<<<< 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.
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.
Possible exit status values are:
There were no differences among the three files.
Some differences were found.
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
With the options that check for overlapping differences (
-Eand -X), the status indicates that there were n overlapping ranges of differences; for example, a status of 3 indicates one overlap.
- 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.
The longest input line is restricted to 1024 characters.
All UNIX systems. Windows 7. Windows Server 2008 R2. Windows 8. Windows Server 2012. Windows 10. Windows Server 2016.
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 MKS Toolkit 10.1 Documentation Build 15.