Compare Files: diff, cmp



next up previous contents index
Next: Unix's File Editor: Up: Unix Toolkit Previous: Manipulate Columns: Cut

Compare Files: diff, cmp

Often we need to know the differences between files. For text files we get the differences with diff and for binary files we use cmp. If no output is given, then the files are the same:
     

% diff prog.f prog2.f   	Compare two Fortran programs.   
%    	No output, identical files.   
% diff pert2.f pert3.f   	Another example.   
4c4   	Line 4 in pert2.f, line 4 in pert3.f.   
<   PROGRAM PERT2 ...   	Lines in file 1.   
>   PROGRAM PERT3 ...   	Lines in file 2   

If you are tired of no one giving you a yes-no answer anymore, then the cmp command is for you (particularly since you do not want to read or print binary files). As an example, we ask the shell if the program pert in rubin's directory is the same as the one in the present directory:

% cmp /u/rubin/pert pert   	Compare binary, executable, files.   
/u/rubin/pert pert differ: char 25 line1   	   



next up previous contents index
Next: Unix's File Editor: Up: Unix Toolkit Previous: Manipulate Columns: Cut