You need to use diff command to display line-by-line difference between two files. The general syntax of diff command as follows:
diff FILE1 FILE2
Where,
FILE1 FILE2: Diff command will examine both file1 and file2 and tells you what changes need to be made for file1 and file2 to match. Please note that diff command point to which lines need be:
- Added (a)
- Deleted (d)
- Changed (c)
- Further lines in file1 identified with a less than () symbol and lines in file2 with a grater than (>) symbol.
Examples
diff file1.txt file2.txt
Output:
8c8,9 URL: www.nixcraft.in > Email: support@nixcraft.in
The contents of both files:
$ cat file1.txt
Output:
Welcome to nixCraft! If undeliverd return to nixCraft #404, DC bay area, 2nd phase, Pune. Ph: 555-11112223 URL: www.nixcraft.com
$ cat file2.txt
Output:
Welcome to nixCraft! If undeliverd return to nixCraft #404, DC bay area, 2nd phase, Pune. Ph: 555-11112223 URL: www.nixcraft.in Email: support@nixcraft.in
Side-by-side merge of file differences
You can get a clear-cut visual difference between two text files using the command sdiff:
$ sdiff file1.txt file2.txt
Output:
Welcome to nixCraft! Welcome to nixCraft!
If undeliverd return to nixCraft If undeliverd return to nixCraft
#404, DC bay area, 2nd phase, #404, DC bay area, 2nd phase,
Pune. Pune.
Ph: 555-11112223 Ph: 555-11112223
URL: www.nixcraft.com | URL: www.nixcraft.in
> Email: support@nixcraft.in 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











{ 2 comments… read them below or add one }
for who prefers a visual tool, I recommend meld (http://meld.sourceforge.net/)
One more time, cyberciti help me a lot. Thanks and nice site. I became an user site.