diff3 command in Linux with examples Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report diff3 command is used to compare the three files line by line. It internally uses the diff command to compare. When three files are compared then the following output may come which have their own meaning: ==== : It means all the files are different. ====1 : File 1 is different. ====2 : File 2 is different. ====3 : File 3 is different. Syntax: diff3 [OPTIONS] Example: Let us consider three files as a.txt, b.txt and c.txt. Now if diff3 command is used over these three files then following output will come: Here, the very first line ‘====3’ tells that the file number 3 i.e. c.txt is different from the other two. This is visible in the output too. Options: 'c' signifies change while ‘a’ signifies append : 'c' signifies ‘change’ required in the lines/text. If the alphabet ‘a’ appears then it signifies a line needs to be appended. Example: Now if diff3 command is used over these three files : The output above signifies that the change in file3 (i.e c.txt) needs to be appended in file1 (a.txt) and file2 (b.txt) to make all the three file similar. Alternatively, the second line in b.txt can be changed(c) to make all the three files similar. -x : It produces an editor script of only those changes where all three files differ. Example: Apply diff3 -x The output says that the third line of a.txt has to changed to ‘mahi’ in order to merge the changes that would turn b.txt to c.txt. diff3 -X : It is similar to -x except that it also checks for overlapping ranges of lines in the changes. diff3 highlights these ranges in the output. Example: Apply diff3 -X diff3 -e : It can be used to output non merged changes from b.txt to c.txt into a.txt. Example: Apply diff3 -e So we see that the output shows the non merged changes. diff3 -E : It also checks for overlapping ranges of lines in the changes. diff3 highlights these ranges in the output. Example: Apply diff3 -E diff3 -m : A merged file comprising of contents from all the three files can be produced using the -m option. Example: Applying diff3 -m So the above output shows contents of the merged file that has merged contents from all the three files supplied as arguments to diff3. diff3 '-' : Accept one argument from stdin using '-'. A '-' can be used in place of any one of the file names to accept input from stdin for that argument. Example: Output: As we can see, when the command above was run, the content of third file was given through stdin. Note that after entering the contents of file from stdin, one needs to press the key combination ctrl+d to get the output of diff3. diff3 -a : To compare even non text files, an option -a can be used that tells diff3 to consider all input files as text files. Example: So the output above shows that diff3 tried to compare even an odt file treating it as a text file. Create Quiz Comment M mahimabadjate Follow 1 Improve M mahimabadjate Follow 1 Improve Article Tags : Linux-Unix Explore Getting Started with LinuxIntroduction to Linux Operating System7 min readLINUX Full Form - Lovable Intellect Not Using XP2 min readDifference between Linux and Windows7 min readLinux Distributions6 min readDifference between Unix and Linux6 min readInstallation with LinuxInstallation of Arch Linux in VirtualBox4 min readFedora Linux Operating System5 min readHow to install Ubuntu on VirtualBox?6 min readHow to Install Linux Mint?3 min readInstallation of Kali Linux in Virtual Machine2 min readHow to Install Linux on Windows PowerShell Subsystem?2 min readHow to Find openSUSE Linux Version?2 min readInstallation of CentOS2 min readLinux CommandsLinux Commands15+ min readEssential Unix Commands7 min readFind Command in Linux with Examples7 min readLinux File SystemLinux File System12 min readLinux File Hierarchy Structure5 min readLinux Directory Structure6 min readLinux KernelLinux Kernel4 min readKernel in Operating System3 min readHow Linux Kernel Boots?11 min readDifference between Operating System and Kernel3 min readLinux Kernel Module Programming: Hello World Program7 min readLinux Loadable Kernel Module7 min readLoadable Kernel Module - Linux Device Driver Development4 min readLinux Networking ToolsNetwork configuration and troubleshooting commands in Linux5 min readHow to configure network interfaces in CentOS?5 min readCommand-Line Tools and Utilities For Network Management in Linux8 min readLinux - Network Monitoring Tools4 min readLinux ProcessProcesses in Linux/Unix5 min readHow to Manage Process in Linux4 min readGetting System and Process Information Using C Programming and Shell in Linux2 min readProcess states and Transitions in a UNIX Process4 min readLinux FirewallLINUX Firewall7 min readiptables command in Linux with Examples7 min readHow to Configure your Linux Firewall - 3 Methods12 min readShell Scripting & Bash ScriptingIntroduction to Linux Shell and Shell Scripting7 min readUnderstanding Terminal, Console, Shell and Kernel3 min readHow to Create a Shell Script in linux7 min readShell Scripting - Different types of Variables4 min readBash Scripting - Introduction to Bash and Bash Scripting12 min readBash Script - Define Bash Variables and its types12 min readShell Scripting - Shell Variables6 min readBash Script - Difference between Bash Script and Shell Script4 min readShell Scripting - Difference between Korn Shell and Bash shell3 min readShell Scripting - Interactive and Non-Interactive Shell3 min readShell Script to Show the Difference Between echo â$SHELLâ and echo â$SHELLâ4 min readLinux Administrator SystemWhat is Linux System Administration?6 min readBeginner's Guide to Linux System Administration5 min readHow to Monitor System Usage, Outages and Troubleshoot Linux Servers6 min readLinux - Systemd and its Components3 min readBoot Process with Systemd in Linux3 min readHow to Control Systemd Services on Remote Linux Server2 min readHow to Start, Stop and Restart Services in Linux Using systemctl Command9 min read Like