Show Difference Between Two Files

How to show the difference between  two files?

Unix Command:

diff  filename  filename2

This command will compare the contents of two files and will tell you exactly what and where the differences between them are. 

For example, perhaps you created a file then later went back and edited that file and saved it under a new name. Now you need to review exactly what changes you made.

The order of your output will be contingent upon which filename you enter first in the command line. The line(s) from the first file listed are marked by a < while the line(s) from the second file are indicated by the > symbol. The numbers given to you correspond to the line numbers where the differences can be located.

In the following example, a difference appears on line 4, an extra line appears in the second file (line 5). Then another difference between corresponding lines is found between line 8 in the first file and line 9 in the second file. 

NOTE: Because of the extra line in the second file (line 5) the numbering has become incongruent.

%    diff  test1.sps  test2.sps

4c4,5
< crosstabs  sex  by  race 
-- 
> crosstabs  age  by  race 

> crosstabs income by race 8c9 
<  correlations  sex  with  educ 
--
>  correlations  age  with  educ
%

Have a Unix Problem
Unix Forum - Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.