Examples of using the diff command

To compare the contents of two files:

   diff email addresses
   2a3,4
   > Jean [email protected]
   > 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  [email protected]              2 Joe  [email protected]
3 Kim  [email protected]                  3 Jean [email protected]
4 Keith keith@festival		4 Jim  jim@frolix8
                                5 Kim  [email protected]
                                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] [Search] [Index]