Contrasting two text files: sdiff

To display a clear visual contrast between two text files use the command:

   sdiff file1 file2

sdiff displays each line of the two files side by side, making it easier for you to see the difference between them.

Lines that are different are shown with a | symbol. Lines unique to file1 are identified by a < symbol; lines unique to file2 with a >. A blank line indicates that the lines are identical.

Example

To contrast two files:

   sdiff -w 80 email addresses
   Mike erpl08@ed                  | John erpl08@ed
   Joe  CZT@cern.ch                Joe  CZT@cern.ch
                                   >  Jean JRS@pollux.ucs.co
                                   >  Jim  jim@frolix8
   Kim  ks@x.co                    Kim  ks@x.co
   Sam  s.wally@aston              <
   Keith keith@festival            Keith keith@festival

This contrasts the two files email on the left and addresses on the right.

The option -w 80 is used to set the width of the output from the command to 80 characters - the most that will fit across most computer terminals. The default is 130 characters.

The first line in each file is different and is marked with a |. Lines 3 and 4 of the file addresses are unique as is line 6 of the file email. All the other lines are identical.