Examples of using the diff command

To compare the contents of two files:

   diff email addresses
   2a3,4
   > Jean JRS@pollux.ucs.co
   > Jim  jim@frolix8

This displays a line by line difference between the file email and addresses.

To make these files match you need to add (a) lines 3 and 4 (3,4) of the file addresses (>) after line 2 in the file email.

Here are the contents of files email and addresses used in this example. Line numbers are shown at the beginning of each line to help you follow this example.

email                           addresses
1 John erpl08@ed                1 John erpl08@ed
2 Joe  CZT@cern.ch              2 Joe  CZT@cern.ch
3 Kim  ks@x.co                  3 Jean JRS@pollux.ucs.co
4 Keith keith@festival		4 Jim  jim@frolix8
                                5 Kim  ks@x.co
                                6 Keith keith@festival

To compare two files ignoring differences in the case of the letters and blank spaces:

   diff -iw part1 part_one

Lines in the two files that differ only in case and by the number of spaces they contain are considered to be identical.


[Home] [Index]