diff3 command in Linux with examples Last Updated : 11 Jul, 2025 Suggest changes Share Like Article 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. M mahimabadjate Follow Article Tags : Linux-Unix Explore Linux/Unix Tutorial 10 min read Getting Started with LinuxWhat is Linux Operating System 10 min read LINUX Full Form - Lovable Intellect Not Using XP 2 min read Difference between Linux and Windows 7 min read What are Linux Distributions ? 8 min read Difference between Unix and Linux 5 min read Installation with LinuxHow to Install Arch Linux in VirtualBox? 7 min read Fedora Linux Operating System 12 min read How to install Ubuntu on VirtualBox? 6 min read How to Install Linux Mint? 3 min read How to Install Kali Linux on Windows? 2 min read How to Install Linux on Windows PowerShell Subsystem? 2 min read How to Find openSUSE Linux Version? 2 min read How to Install CentOS 2 min read Linux CommandsLinux Commands 15+ min read Essential Unix Commands 7 min read How to Find a File in Linux | Find Command 9 min read Linux File SystemLinux File System 12 min read Linux File Hierarchy Structure 6 min read Linux Directory Structure 6 min read Linux KernelLinux Kernel 4 min read Kernel in Operating System 3 min read How Linux Kernel Boots? 11 min read Difference between Operating System and Kernel 3 min read Linux Kernel Module Programming: Hello World Program 7 min read Linux Loadable Kernel Module 7 min read Loadable Kernel Module - Linux Device Driver Development 4 min read Linux Networking ToolsNetwork configuration and troubleshooting commands in Linux 5 min read How to configure network interfaces in CentOS? 5 min read Command-Line Tools and Utilities For Network Management in Linux 8 min read Linux - Network Monitoring Tools 4 min read Linux ProcessProcesses in Linux/Unix 6 min read How to Manage Process in Linux 4 min read Getting System and Process Information Using C Programming and Shell in Linux 2 min read Process states and Transitions in a UNIX Process 4 min read Linux FirewallLINUX Firewall 7 min read iptables command in Linux with Examples 7 min read How to Configure your Linux Firewall - 3 Methods 12 min read Shell Scripting & Bash ScriptingIntroduction to Linux Shell and Shell Scripting 8 min read What is Terminal, Console, Shell and Kernel? 5 min read How to Create a Shell Script in linux 7 min read Shell Scripting - Different types of Variables 4 min read Bash Scripting - Introduction to Bash and Bash Scripting 12 min read Bash Script - Define Bash Variables and its types 12 min read Shell Scripting - Shell Variables 6 min read Bash Script - Difference between Bash Script and Shell Script 4 min read Shell Scripting - Difference between Korn Shell and Bash shell 3 min read Shell Scripting - Interactive and Non-Interactive Shell 3 min read Shell Script to Show the Difference Between echo â$SHELLâ and echo â$SHELLâ 4 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like