[Next] [Previous] [Up] [Top] [Contents]

8.1 Working With Files

8.1.2 diff - differences in files

The diff command compares two files, directories, etc, and reports all differences between the two. It deals only with ASCII files. It's output format is designed to report the changes necessary to convert the first file into the second.


diff [options] file1 file2

Common Options

-b ignore trailing blanks

-i ignore the case of letters

-w ignore <space> and <tab> characters

-e produce an output formatted for use with the editor, ed

-r apply diff recursively through common sub-directories


For the mon.logins and tues.logins files above, the difference between them is given by:

% diff mon.logins tues.logins


< bsmith


> jdoe


< mschmidt


> proy

Note that the output lists the differences as well as in which file the difference exists. Lines in the first file are preceded by "< ", and those in the second file are preceded by "> ".

Introduction to Unix - 14 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]