Finding Differences

Finding Differences

If you’re like me, documents take up no small part of your life. Whether they’re text or formatted by some other word processing program, I’ve always got a pile of revisions awaiting review and collation.

diff is the program for you if you’re looking to compare those document revisions. diff works by comparing two text documents and outputting the lines that differ from one to the other. The convention for using diff is:

    diff [options] [diroptions] file1 file2

diff will also compare files within directories. For example, let’s say you’ve got a “new” directory and an “old” directory containing similar filenames. Given directory names as arguments, diff will report back all differing lines between similar filenames in both directories.

Here’s a set of options to utilize when using diff:

OptionAction
atreat all files as text files
bignore repeating and end-of-line blanks
Bignore blank lines
ccontext diff – print 3 lines surrounding each changed line
dignore sets of numerous changes and output a smaller set
Hdisplay only scattered small changes, large sections with many changes may not appear
iignore case changes
qoutput only whether files differ
rcompare subdirectories recursively
wignore all whitespace in files

Looking for differences? diff will root them out without a problem.