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
, or
d
) that would be used to convert
file1
to
file2
. If one of the files is
-
, standard
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 arguments 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
sdiff
and
cmp
.
-
-b
-
Ignore repeating blanks and end-of-line blanks; treat successive blanks
as one.
-
-c
-
Produce output in alternate format, with three lines of context.
-
-C
n
-
Like
-c
, but produce
n
lines of context.
-
-c
n
-
Produce
n
lines of context (default is 3).
-
-D
def
-
Merge
file1
and
file2
into a single file containing
conditional C preprocessor directives (
#ifdef
). Defining
def
and then compiling will yield
file2
; compiling without
defining
def
yields
file1
.
-
-e
-
Produce a script of commands (
a
,
c
,
d
) to
recreate
file2
from
file1
using the ed editor.
-
-f
-
Produce a script to recreate
file1
from
file2
; the script
is in the opposite order, so it isn't useful to ed.
-
-h
-
Do a half-hearted comparison; complex differences (e.g., long stretches of many
changes) may not show up;
-e
and
-f
are disabled.
-
-i
-
Ignore uppercase and lowercase distinctions.
-
-n
-
Like
-f
, but counts changed lines.
rcsdiff
works this
way.
-
-t
-
Expand tabs in output lines; useful for preserving indentation changed
by
-c
format.
-
-w
-
Like
-b
but ignores all spaces and tabs; e.g.,
a + b
is
the same as
a+b
.
Options
-c
,
-C
,
-D
,
-e
,
-f
,
-h
, and
-n
cannot be combined with each other (they are mutually exclusive).
The following
diroptions
are valid only when both file arguments are
directories.
-
-l
-
Long format; output is paginated by
pr
so that
diff
listings for each file begin on a new page; other comparisons are
listed afterward.
-
-r
-
Run
diff
recursively for files in common subdirectories.
-
-s
-
Report files that are identical.
-
-S
file
-
Begin directory comparisons with
file
, skipping files whose names
are alphabetically before
file
.