≡ Menu

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

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

Add your comment

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

Comments on this entry are closed.

  • RAGHU June 29, 2010, 2:39 am

    Colordiff , Wdiff is not available in RHEL .

  • Moi June 29, 2010, 4:43 am

    meld is the way to go!

  • Jimin June 29, 2010, 5:16 am

    How about tkdiff…
    I like it!!!

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

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

  • BalaC June 29, 2010, 7:47 am

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

  • Saint DanBert June 29, 2010, 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

  • Dom May 22, 2011, 3:16 am

    Another great diff tool written in python

  • jalal hajigholamali July 11, 2011, 2:53 am

    thanks,

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

  • leeladharan August 22, 2011, 10:36 am

    another great tool, kompare in kde