Top 4 File Difference Tools on UNIX / Linux – Diff, Colordiff, Wdiff, Vimdiff

by SathiyaMoorthy on June 29, 2010

For finding difference between two versions of a file on Linux, you can use any one of the 4 tools explained in this article — diff, colordiff, wdiff, and vimdiff.

The screenshots provided for these tools shows the difference between the following two empfile1.txt and empfile2.txt.

$ cat empfile1.txt

John Smith 	1001 	Sr. Engineer
Peter		1002	Engineer
Fernandous	1003	Sr. Engineer
Kraml		1004	Jr. Engineer

$ cat empfile2.txt

John Smith 	1001 	Sr. Engineer
Peter		1002	Engineer
Fernandous	1003	Resigned
Kraml		1004	Jr. Engineer
Raj		1005	Engineer

1. Diff Command

This is the traditional way to find out the difference two files is using diff command.

$ diff empfile1.txt empfile2.txt
3c3
< Fernandous	1003	Sr. Engineer
---
> Fernandous	1003	Resigned
5c5
<
---
> Raj		1005	Engineer

Fig: Diff command output

2. Colordiff Command

Colordiff shows the diff in color as shown below.

Fig: Colordiff Command output

3. Wdiff Command

Wdiff command output:

John Smith 	1001 	Sr. Engineer
Peter		1002	Engineer
Fernandous	1003	[-Sr. Engineer-]	{+Resigned+}
Kraml		1004	Jr. Engineer
{+Raj		1005	Engineer+}
  • It covers the removed word / line with [- -]
  • It covers the added word / line with {+ +}

Fig: Wdiff Command output

4. Vimdiff Command

We discussed earlier about Vimdiff in detail.

Fig: Vimdiff Screenshot


Linux Sysadmin Course Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the Linux Sysadmin Course Now!

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 9 comments… read them below or add one }

1 RAGHU June 29, 2010 at 2:39 am

Colordiff , Wdiff is not available in RHEL .

2 Moi June 29, 2010 at 4:43 am

meld is the way to go!

3 Jimin June 29, 2010 at 5:16 am

How about tkdiff…
I like it!!!

4 Chris F.A. Johnson June 29, 2010 at 6:30 am

You forgot two of the standard utilities: comm and cmp.

5 BalaC June 29, 2010 at 7:47 am

meld is much better. But, still it requires the files to be in the same folder structure.

6 Saint DanBert June 29, 2010 at 8:39 am

There is another tool, diffuse, available from the deb repositories. (I don’t know about
rpm or other packages.) It presents the differences in parallel columns as a GUI.
Scrolling is in sync for each comparison.

~~~ 0;-Dan

7 Dom May 22, 2011 at 3:16 am

Another great diff tool written in python

8 jalal hajigholamali July 11, 2011 at 2:53 am

thanks,

you can download wdiff for rhel from
http://www.gnu.org/software/wdiff/wdiff.html

9 leeladharan August 22, 2011 at 10:36 am

another great tool, kompare in kde

Leave a Comment

Previous post:

Next post: