cvsdist 70d82c0
.TH DIFF 1 "22sep1993" "GNU Tools" "GNU Tools"
cvsdist 70d82c0
.SH NAME
cvsdist 70d82c0
diff \- find differences between two files
cvsdist 70d82c0
.SH SYNOPSIS
cvsdist 70d82c0
.B diff
cvsdist 70d82c0
[options] from-file to-file
cvsdist 70d82c0
.SH DESCRIPTION
cvsdist 70d82c0
In the simplest case, 
cvsdist 70d82c0
.I diff
cvsdist 70d82c0
compares the contents of the two files
cvsdist 70d82c0
.I from-file
cvsdist 70d82c0
and
cvsdist 70d82c0
.IR to-file .
cvsdist 70d82c0
A file name of
cvsdist 70d82c0
.B \-
cvsdist 70d82c0
stands for
cvsdist 70d82c0
text read from the standard input.  As a special case,
cvsdist 70d82c0
.B "diff \- \-"
cvsdist 70d82c0
compares a copy of standard input to itself.
cvsdist 70d82c0
cvsdist 70d82c0
If 
cvsdist 70d82c0
.I from-file
cvsdist 70d82c0
is a directory and
cvsdist 70d82c0
.I to-file
cvsdist 70d82c0
is not,
cvsdist 70d82c0
.I diff
cvsdist 70d82c0
compares the file in
cvsdist 70d82c0
.I from-file
cvsdist 70d82c0
whose file name is that of
cvsdist 70d82c0
.IR to-file ,
cvsdist 70d82c0
and vice versa.  The non-directory file must not be
cvsdist 70d82c0
.BR \- .
cvsdist 70d82c0
cvsdist 70d82c0
If both
cvsdist 70d82c0
.I from-file
cvsdist 70d82c0
and
cvsdist 70d82c0
.I to-file
cvsdist 70d82c0
are directories,
cvsdist 70d82c0
.I diff
cvsdist 70d82c0
compares corresponding files in both directories, in
cvsdist 70d82c0
alphabetical order; this comparison is not recursive unless the
cvsdist 70d82c0
.B \-r
cvsdist 70d82c0
or
cvsdist 70d82c0
.B \-\-recursive
cvsdist 70d82c0
option is given.
cvsdist 70d82c0
.I diff
cvsdist 70d82c0
never
cvsdist 70d82c0
compares the actual contents of a directory as if it were a file.  The
cvsdist 70d82c0
file that is fully specified may not be standard input, because standard
cvsdist 70d82c0
input is nameless and the notion of ``file with the same name'' does not
cvsdist 70d82c0
apply.
cvsdist 70d82c0
cvsdist 70d82c0
.B diff
cvsdist 70d82c0
options begin with
cvsdist 70d82c0
.BR \- ,
cvsdist 70d82c0
so normally
cvsdist 70d82c0
.I from-file
cvsdist 70d82c0
and
cvsdist 70d82c0
.I to-file
cvsdist 70d82c0
may not begin with
cvsdist 70d82c0
.BR \- .
cvsdist 70d82c0
However,
cvsdist 70d82c0
.B \-\-
cvsdist 70d82c0
as an
cvsdist 70d82c0
argument by itself treats the remaining arguments as file names even if
cvsdist 70d82c0
they begin with
cvsdist 70d82c0
.BR \- .
cvsdist 70d82c0
.SS Options
cvsdist 70d82c0
Below is a summary of all of the options that GNU
cvsdist 70d82c0
.I diff
cvsdist 70d82c0
accepts.
cvsdist 70d82c0
Most options have two equivalent names, one of which is a single letter
cvsdist 70d82c0
preceded by
cvsdist 70d82c0
.BR \- ,
cvsdist 70d82c0
and the other of which is a long name preceded by
cvsdist 70d82c0
.BR \-\- .
cvsdist 70d82c0
Multiple single letter options (unless they take an
cvsdist 70d82c0
argument) can be combined into a single command line word:
cvsdist 70d82c0
.B \-ac
cvsdist 70d82c0
is
cvsdist 70d82c0
equivalent to
cvsdist 70d82c0
.BR "\-a \-c" .
cvsdist 70d82c0
Long named options can be abbreviated to
cvsdist 70d82c0
any unique prefix of their name.  Brackets
cvsdist 70d82c0
.RB ( [
cvsdist 70d82c0
and
cvsdist 70d82c0
.BR ] )
cvsdist 70d82c0
indicate that an
cvsdist 70d82c0
option takes an optional argument.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \- lines
cvsdist 70d82c0
Show
cvsdist 70d82c0
.I lines
cvsdist 70d82c0
(an integer) lines of context.  This option does not
cvsdist 70d82c0
specify an output format by itself; it has no effect unless it is
cvsdist 70d82c0
combined with
cvsdist 70d82c0
.B \-c
cvsdist 70d82c0
or
cvsdist 70d82c0
.BR \-u .
cvsdist 70d82c0
This option is obsolete.  For proper
cvsdist 70d82c0
operation,
cvsdist 70d82c0
.I patch
cvsdist 70d82c0
typically needs at least two lines of context.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-a
cvsdist 70d82c0
Treat all files as text and compare them line-by-line, even if they
cvsdist 70d82c0
do not seem to be text.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-b
cvsdist 70d82c0
Ignore changes in amount of white space.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-B
cvsdist 70d82c0
Ignore changes that just insert or delete blank lines.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-brief
cvsdist 70d82c0
Report only whether the files differ, not the details of the
cvsdist 70d82c0
differences.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-c
cvsdist 70d82c0
Use the context output format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI "\-C " lines
cvsdist 70d82c0
.br
cvsdist 70d82c0
.ns
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-context[= lines ]
cvsdist 70d82c0
Use the context output format, showing
cvsdist 70d82c0
.I lines
cvsdist 70d82c0
(an integer) lines of
cvsdist 70d82c0
context, or three if
cvsdist 70d82c0
.I lines
cvsdist 70d82c0
is not given.
cvsdist 70d82c0
For proper operation,
cvsdist 70d82c0
.I patch
cvsdist 70d82c0
typically needs at least two lines of
cvsdist 70d82c0
context.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-changed\-group\-format= format
cvsdist 70d82c0
Use
cvsdist 70d82c0
.I format
cvsdist 70d82c0
to output a line group containing differing lines from
cvsdist 70d82c0
both files in if-then-else format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-d
cvsdist 70d82c0
Change the algorithm to perhaps find a smaller set of changes.  This makes
cvsdist 70d82c0
.I diff
cvsdist 70d82c0
slower (sometimes much slower).
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI "\-D " name
cvsdist 70d82c0
Make merged if-then-else format output, conditional on the preprocessor
cvsdist 70d82c0
macro
cvsdist 70d82c0
.IR name .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-e
cvsdist 70d82c0
.br
cvsdist 70d82c0
.ns
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-ed
cvsdist 70d82c0
Make output that is a valid
cvsdist 70d82c0
.I ed
cvsdist 70d82c0
script.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-exclude= pattern
cvsdist 70d82c0
When comparing directories, ignore files and subdirectories whose basenames
cvsdist 70d82c0
match
cvsdist 70d82c0
.IR pattern .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-exclude\-from= file
cvsdist 70d82c0
When comparing directories, ignore files and subdirectories whose basenames
cvsdist 70d82c0
match any pattern contained in
cvsdist 70d82c0
.IR file .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-expand\-tabs
cvsdist 70d82c0
Expand tabs to spaces in the output, to preserve the alignment of tabs
cvsdist 70d82c0
in the input files.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-f
cvsdist 70d82c0
Make output that looks vaguely like an
cvsdist 70d82c0
.I ed
cvsdist 70d82c0
script but has changes
cvsdist 70d82c0
in the order they appear in the file.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI "\-F " regexp
cvsdist 70d82c0
In context and unified format, for each hunk of differences, show some
cvsdist 70d82c0
of the last preceding line that matches
cvsdist 70d82c0
.IR regexp .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-forward\-ed
cvsdist 70d82c0
Make output that looks vaguely like an
cvsdist 70d82c0
.B ed
cvsdist 70d82c0
script but has changes
cvsdist 70d82c0
in the order they appear in the file.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-h
cvsdist 70d82c0
This option currently has no effect; it is present for Unix
cvsdist 70d82c0
compatibility.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-H
cvsdist 70d82c0
Use heuristics to speed handling of large files that have numerous
cvsdist 70d82c0
scattered small changes.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-horizon\-lines= lines
cvsdist 70d82c0
Do not discard the last
cvsdist 70d82c0
.I lines
cvsdist 70d82c0
lines of the common prefix
cvsdist 70d82c0
and the first
cvsdist 70d82c0
.I lines
cvsdist 70d82c0
lines of the common suffix.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-i
cvsdist 70d82c0
Ignore changes in case; consider upper- and lower-case letters
cvsdist 70d82c0
equivalent.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI "\-I " regexp
cvsdist 70d82c0
Ignore changes that just insert or delete lines that match
cvsdist 70d82c0
.IR regexp .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-ifdef= name
cvsdist 70d82c0
Make merged if-then-else format output, conditional on the preprocessor
cvsdist 70d82c0
macro
cvsdist 70d82c0
.IR name .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-ignore\-all\-space
cvsdist 70d82c0
Ignore white space when comparing lines.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-ignore\-blank\-lines
cvsdist 70d82c0
Ignore changes that just insert or delete blank lines.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-ignore\-case
cvsdist 70d82c0
Ignore changes in case; consider upper- and lower-case to be the same.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-ignore\-matching\-lines= regexp
cvsdist 70d82c0
Ignore changes that just insert or delete lines that match
cvsdist 70d82c0
.IR regexp .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-ignore\-space\-change
cvsdist 70d82c0
Ignore changes in amount of white space.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-initial\-tab
cvsdist 70d82c0
Output a tab rather than a space before the text of a line in normal or
cvsdist 70d82c0
context format.  This causes the alignment of tabs in the line to look
cvsdist 70d82c0
normal.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-l
cvsdist 70d82c0
Pass the output through
cvsdist 70d82c0
.I pr
cvsdist 70d82c0
to paginate it.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI "\-L " label
cvsdist 70d82c0
.br
cvsdist 70d82c0
.ns
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-label= label
cvsdist 70d82c0
Use
cvsdist 70d82c0
.I label
cvsdist 70d82c0
instead of the file name in the context format
cvsdist 70d82c0
and unified format
cvsdist 70d82c0
headers.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-left\-column
cvsdist 70d82c0
Print only the left column of two common lines in side by side format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-line\-format= format
cvsdist 70d82c0
Use
cvsdist 70d82c0
.I format
cvsdist 70d82c0
to output all input lines in in-then-else format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-minimal
cvsdist 70d82c0
Change the algorithm to perhaps find a smaller set of changes.  This
cvsdist 70d82c0
makes
cvsdist 70d82c0
.I diff
cvsdist 70d82c0
slower (sometimes much slower).
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-n
cvsdist 70d82c0
Output RCS-format diffs; like
cvsdist 70d82c0
.B \-f
cvsdist 70d82c0
except that each command
cvsdist 70d82c0
specifies the number of lines affected.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-N
cvsdist 70d82c0
.br
cvsdist 70d82c0
.ns
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-new\-file
cvsdist 70d82c0
In directory comparison, if a file is found in only one directory,
cvsdist 70d82c0
treat it as present but empty in the other directory.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-new\-group\-format= format
cvsdist 70d82c0
Use
cvsdist 70d82c0
.I format
cvsdist 70d82c0
to output a group of lines taken from just the second
cvsdist 70d82c0
file in if-then-else format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-new\-line\-format= format
cvsdist 70d82c0
Use 
cvsdist 70d82c0
.I format
cvsdist 70d82c0
to output a line taken from just the second file in
cvsdist 70d82c0
if-then-else format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-old\-group\-format= format
cvsdist 70d82c0
Use
cvsdist 70d82c0
.I format
cvsdist 70d82c0
to output a group of lines taken from just the first
cvsdist 70d82c0
file in if-then-else format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-old\-line\-format= format
cvsdist 70d82c0
Use
cvsdist 70d82c0
.I format
cvsdist 70d82c0
to output a line taken from just the first file in
cvsdist 70d82c0
if-then-else format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-p
cvsdist 70d82c0
Show which C function each change is in.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-P
cvsdist 70d82c0
When comparing directories, if a file appears only in the second
cvsdist 70d82c0
directory of the two, treat it as present but empty in the other.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-paginate
cvsdist 70d82c0
Pass the output through
cvsdist 70d82c0
.I pr
cvsdist 70d82c0
to paginate it.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-q
cvsdist 70d82c0
Report only whether the files differ, not the details of the
cvsdist 70d82c0
differences.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-r
cvsdist 70d82c0
When comparing directories, recursively compare any subdirectories
cvsdist 70d82c0
found.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-rcs
cvsdist 70d82c0
Output RCS-format diffs; like
cvsdist 70d82c0
.B \-f
cvsdist 70d82c0
except that each command
cvsdist 70d82c0
specifies the number of lines affected.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-recursive
cvsdist 70d82c0
When comparing directories, recursively compare any subdirectories
cvsdist 70d82c0
found.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-report\-identical\-files
cvsdist 70d82c0
.br
cvsdist 70d82c0
.ns
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-s
cvsdist 70d82c0
Report when two files are the same.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI "\-S " file
cvsdist 70d82c0
When comparing directories, start with the file
cvsdist 70d82c0
.IR file .
cvsdist 70d82c0
This is
cvsdist 70d82c0
used for resuming an aborted comparison.
cvsdist 70d82c0
.TP
cvsdist 2d3189a
.BI \-\-from\-file= file
cvsdist 2d3189a
Compare
cvsdist 2d3189a
.I file
cvsdist 2d3189a
to all operands.
cvsdist 2d3189a
.I file
cvsdist 2d3189a
can be a directory.
cvsdist 2d3189a
.TP
cvsdist 2d3189a
.BI \-\-to\-file= file
cvsdist 2d3189a
Compare all operands to
cvsdist 2d3189a
.IR file . " file"
cvsdist 2d3189a
can be a directory.
cvsdist 2d3189a
.TP
cvsdist 70d82c0
.B \-\-sdiff\-merge\-assist
cvsdist 70d82c0
Print extra information to help
cvsdist 70d82c0
.IR sdiff .
cvsdist 70d82c0
.I sdiff
cvsdist 70d82c0
uses this
cvsdist 70d82c0
option when it runs
cvsdist 70d82c0
.IR diff .
cvsdist 70d82c0
This option is not intended for users
cvsdist 70d82c0
to use directly.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-show\-c\-function
cvsdist 70d82c0
Show which C function each change is in.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-show\-function\-line= regexp
cvsdist 70d82c0
In context and unified format, for each hunk of differences, show some
cvsdist 70d82c0
of the last preceding line that matches
cvsdist 70d82c0
.IR regexp .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-side\-by\-side
cvsdist 70d82c0
Use the side by side output format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-speed\-large\-files
cvsdist 70d82c0
Use heuristics to speed handling of large files that have numerous
cvsdist 70d82c0
scattered small changes.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-starting\-file= file
cvsdist 70d82c0
When comparing directories, start with the file
cvsdist 70d82c0
.IR file .
cvsdist 70d82c0
This is
cvsdist 70d82c0
used for resuming an aborted comparison.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-suppress\-common\-lines
cvsdist 70d82c0
Do not print common lines in side by side format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-t
cvsdist 70d82c0
Expand tabs to spaces in the output, to preserve the alignment of tabs
cvsdist 70d82c0
in the input files.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-T
cvsdist 70d82c0
Output a tab rather than a space before the text of a line in normal or
cvsdist 70d82c0
context format.  This causes the alignment of tabs in the line to look
cvsdist 70d82c0
normal.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-text
cvsdist 70d82c0
Treat all files as text and compare them line-by-line, even if they
cvsdist 70d82c0
do not appear to be text.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-u
cvsdist 70d82c0
Use the unified output format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-unchanged\-group\-format= format
cvsdist 70d82c0
Use
cvsdist 70d82c0
.I format
cvsdist 70d82c0
to output a group of common lines taken from both files
cvsdist 70d82c0
in if-then-else format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-unchanged\-line\-format= format
cvsdist 70d82c0
Use
cvsdist 70d82c0
.I format
cvsdist 70d82c0
to output a line common to both files in if-then-else
cvsdist 70d82c0
format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-unidirectional\-new\-file
cvsdist 70d82c0
When comparing directories, if a file appears only in the second
cvsdist 70d82c0
directory of the two, treat it as present but empty in the other.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI "\-U " lines
cvsdist 70d82c0
.br
cvsdist 70d82c0
.ns
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-unified[= lines ]
cvsdist 70d82c0
Use the unified output format, showing
cvsdist 70d82c0
.I lines
cvsdist 70d82c0
(an integer) lines of
cvsdist 70d82c0
context, or three if
cvsdist 70d82c0
.I lines
cvsdist 70d82c0
is not given.
cvsdist 70d82c0
For proper operation,
cvsdist 70d82c0
.I patch
cvsdist 70d82c0
typically needs at least two lines of
cvsdist 70d82c0
context.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-v
cvsdist 70d82c0
.br
cvsdist 70d82c0
.ns
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-\-version
cvsdist 70d82c0
Output the version number of
cvsdist 70d82c0
.IR diff .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-w
cvsdist 70d82c0
Ignore white space when comparing lines.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI "\-W " columns
cvsdist 70d82c0
.br
cvsdist 70d82c0
.ns
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI \-\-width= columns
cvsdist 70d82c0
Use an output width of
cvsdist 70d82c0
.I columns
cvsdist 70d82c0
in side by side format.
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI "\-x " pattern
cvsdist 70d82c0
When comparing directories, ignore files and subdirectories whose basenames
cvsdist 70d82c0
match
cvsdist 70d82c0
.IR pattern .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.BI "\-X " file
cvsdist 70d82c0
When comparing directories, ignore files and subdirectories whose basenames
cvsdist 70d82c0
match any pattern contained in
cvsdist 70d82c0
.IR file .
cvsdist 70d82c0
.TP
cvsdist 70d82c0
.B \-y
cvsdist 70d82c0
Use the side by side output format.
cvsdist 70d82c0
.SH SEE ALSO
cvsdist 70d82c0
cmp(1), comm(1), diff3(1), ed(1), patch(1), pr(1), sdiff(1).
cvsdist 70d82c0
.SH DIAGNOSTICS
cvsdist 70d82c0
An exit status of 0 means no differences were found, 1 means some
cvsdist 70d82c0
differences were found, and 2 means trouble.