Up:Invoking diff
Options to diff
Below is a summary of all of the options that GNU diff accepts.
Most options have two equivalent names, one of which is a single letter
preceded by -, and the other of which is a long name preceded by
--. Multiple single letter options (unless they take an
argument) can be combined into a single command line word: -ac is
equivalent to -a -c. Long named options can be abbreviated to
any unique prefix of their name. Brackets ([ and ]) indicate that an
option takes an optional argument.
- -b
- --ignore-space-change
- Ignore changes in amount of white space. See White Space.
- -B
- --ignore-blank-lines
- Ignore changes that just insert or delete blank lines. See Blank Lines.
- -c
- Use the context output format, showing three lines of context.
See Context Format.
- -C lines
- --context[=lines]
- Use the context output format, showing lines (an integer) lines of
context, or three if lines is not given. See Context Format.
For proper operation, patch typically needs at least two lines of
context.
On older systems, diff supports an obsolete option
-lines that has effect when combined with -c
or -p. POSIX 1003.1-2001 (see Standards conformance) does not allow this; use -C lines
instead.
- --changed-group-format=format
- Use format to output a line group containing differing lines from
both files in if-then-else format. See Line Group Formats.
- -D name
- --ifdef=name
- Make merged #ifdef format output, conditional on the preprocessor
macro name. See If-then-else.
- -E
- --ignore-tab-expansion
- Ignore changes due to tab expansion.
See White Space.
- -F regexp
- --show-function-line=regexp
- In context and unified format, for each hunk of differences, show some
of the last preceding line that matches regexp. See Specified Headings.
- --from-file=file
- Compare file to each operand; file may be a directory.
- -i
- --ignore-case
- Ignore changes in case; consider upper- and lower-case letters
equivalent. See Case Folding.
- -I regexp
- --ignore-matching-lines=regexp
- Ignore changes that just insert or delete lines that match regexp.
See Specified Folding.
- --label=label
- Use label instead of the file name in the context format
(see Context Format) and unified format (see Unified Format)
headers.
- --left-column
- Print only the left column of two common lines in side by side format.
See Side by Side Format.
- --line-format=format
- Use format to output all input lines in if-then-else format.
See Line Formats.
- -N
- --new-file
- In directory comparison, if a file is found in only one directory,
treat it as present but empty in the other directory. See Comparing Directories.
- --new-group-format=format
- Use format to output a group of lines taken from just the second
file in if-then-else format. See Line Group Formats.
- --new-line-format=format
- Use format to output a line taken from just the second file in
if-then-else format. See Line Formats.
- --old-group-format=format
- Use format to output a group of lines taken from just the first
file in if-then-else format. See Line Group Formats.
- --old-line-format=format
- Use format to output a line taken from just the first file in
if-then-else format. See Line Formats.
- -p
- --show-c-function
- Show which C function each change is in. See C Function Headings.
- -q
- --brief
- Report only whether the files differ, not the details of the
differences. See Brief.
- -r
- --recursive
- When comparing directories, recursively compare any subdirectories
found. See Comparing Directories.
- -s
- --report-identical-files
- Report when two files are the same. See Comparing Directories.
- --strip-trailing-cr
- Strip any trailing carriage return at the end of an input line.
- --suppress-common-lines
- Do not print common lines in side by side format.
See Side by Side Format.
- -t
- --expand-tabs
- Expand tabs to spaces in the output, to preserve the alignment of tabs
in the input files. See Tabs.
- -T
- --initial-tab
- Output a tab rather than a space before the text of a line in normal or
context format. This causes the alignment of tabs in the line to look
normal. See Tabs.
- --to-file=file
- Compare each operand to file; file may be a directory.
- -u
- Use the unified output format, showing three lines of context.
See Unified Format.
- --unchanged-group-format=format
- Use format to output a group of common lines taken from both files
in if-then-else format. See Line Group Formats.
- --unchanged-line-format=format
- Use format to output a line common to both files in if-then-else
format. See Line Formats.
- --unidirectional-new-file
- When comparing directories, if a file appears only in the second
directory of the two, treat it as present but empty in the other.
See Comparing Directories.
- -U lines
- --unified[=lines]
- Use the unified output format, showing lines (an integer) lines of
context, or three if lines is not given. See Unified Format.
For proper operation, patch typically needs at least two lines of
context.
On older systems, diff supports an obsolete option
-lines that has effect when combined with -u.
POSIX 1003.1-2001 (see Standards conformance) does not allow
this; use -U lines instead.
- -w
- --ignore-all-space
- Ignore white space when comparing lines. See White Space.
- -W columns
- --width=columns
- Output at most columns (default 130) print columns per line in
side by side format. See Side by Side Format.
- -x pattern
- --exclude=pattern
- When comparing directories, ignore files and subdirectories whose basenames
match pattern. See Comparing Directories.
- -y
- --side-by-side
- Use the side by side output format. See Side by Side Format.