
118
|
Chapter 3: Linux Commands
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
diff
diff [options] [diroptions] file1 file2
Compare two text files. diff reports lines that differ between file1
and file2. Output consists of lines of context from each file, with
file1 text flagged by a < symbol and file2 text by a > symbol.
Context lines are preceded by the ed command (a, c,ord) that
would be used to convert file1 to file2. If one of the files is -, stan-
dard input is read. If one of the files is a directory, diff locates the
filename in that directory corresponding to the other argument (e.g.,
diff my_dir junk is the same as diff my_dir/junk junk). If both argu-
ments are directories, diff reports lines that differ between all pairs
of files having equivalent names (e.g., olddir/program and newdir/
program); in addition, diff lists filenames unique to one directory, as
well as subdirectories common to both. See also cmp.
Options
-a, --text
Treat all files as text files. Useful for checking to see if binary
files are identical.
-b, --ignore-space-change
Ignore repeating blanks and end-of-line blanks; treat succes-
sive blanks as one.
-B, --ignore-blank-lines
Ignore blank lines in files.
-c Context diff: print 3 lines surrounding each changed line.
-C n, --context[=n]
Context diff: print n lines surrounding each changed line. The
default context ...