The diff command compare files line by line and displays a list of changes between two file. You can use diff command to:
- See the changes between one version of a file.
- Compare two configuration or program files.
- Create a patch file which can be applied with the Linux / Unix program patch.
Say hello to colordiff
colordiff is a wrapper for diff and produces the same output as diff but with coloured syntax highlighting at the command line to improve readability. colordiff has been tested on various flavours of Linux and under OpenBSD, but should be broadly portable to other systems.
Installation
First, turn on the EPEL repo and type the following yum command to install colordiff utility:
# yum install colordiff
Sample outputs:
Loaded plugins: product-id, protectbase, rhnplugin 0 packages excluded due to repository protections Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package colordiff.noarch 0:1.0.9-3.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================== Package Arch Version Repository Size =============================================================================== Installing: colordiff noarch 1.0.9-3.el6 epel 23 k Transaction Summary =============================================================================== Install 1 Package(s) Total download size: 23 k Installed size: 43 k Is this ok [y/N]: y Downloading Packages: colordiff-1.0.9-3.el6.noarch.rpm | 23 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : colordiff-1.0.9-3.el6.noarch 1/1 Installed products updated. Verifying : colordiff-1.0.9-3.el6.noarch 1/1 Installed: colordiff.noarch 0:1.0.9-3.el6 Complete!
Debian / Ubuntu / Mint Linux users type the following apt-get command to install colordiff utility:
$ sudo apt-get install colordiff
Sample outputs:
[sudo] password for vivek: Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: colordiff 0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded. Need to get 14.4 kB of archives. After this operation, 65.5 kB of additional disk space will be used. Get:1 http://debian.osuosl.org/debian/ squeeze/main colordiff all 1.0.9-1 [14.4 kB] Fetched 14.4 kB in 1s (12.8 kB/s) Selecting previously deselected package colordiff. (Reading database ... 281091 files and directories currently installed.) Unpacking colordiff (from .../colordiff_1.0.9-1_all.deb) ... Processing triggers for man-db ... Setting up colordiff (1.0.9-1) ...
How do I use colordiff command?
The syntax is:
colordiff file1 file2
OR
diff -u file1 file2 | colordiff
You can pipe the output to less command, using the -R or -r option which keeps the color escape sequences, otherwise displayed incorrectly or discarded by less:
diff -u file1 file2 | colordiff | less -R
Sample outputs:
Alternatives to colordiff command
Use remark command as follows:
diff file1 file2 | remark /usr/share/regex-markup/diff
You can also use the grc command:
grc diff file1 file2
Use the following syntax to read man page for information about colordiff and diff command:
man diff
man colordiff
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop










![Top 8 Tools To Search Memory Under Linux / Unix [ Forensics Analysis ]](http://s13.cyberciti.org/images/shared/rp/3/22.jpg)
