Linux diff3 command: compare 3 files by line
Linux diff3 command Function Description
Use the diff3 command to compare 3 files by line.
Linux diff3 command Syntax
diff3 [option] [file1] [file2] [file3]
The meaning of each option in the command is shown in the table:
Option | Description |
---|---|
-A | Export all changes |
-X | Output overlapping change sections |
-3 | Output unmerged non-overlapping changes |
-x | Changes in output overlap |
-m | Output the merged file, not the ed script |
-L <tag> |
Use tags instead of filenames |
-i | Adding w and q commands to edit scripts |
-a | Treat all documents as text |
-T | Make the tag preceded by a tag queue |
-e | Output the unmerged changes from file 2 and file 3 and insert them into file 1 |
-E | Exporting unmerged changes |
--diff-program=<program> |
Use the specified program to compare files |
Linux diff3 command Demo
Compare the files /root/a, /root/b and /root/c by line
[root@rhel ~]# diff3 /root/a /root/b /root/c
====
1:1c
a
2:1c
b
3:1c
c
Compare the files apidemos.com.sort.txt, apidemos.com.txt and apidemos.com.3.txt by line
diff3 apidemos.com.sort.txt apidemos.com.txt apidemos.com.3.txt
Output: