• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

diff

diff

diff Finds differences between two files.
diff [options] <from-file>
									<to-file>
								

In its simplest form, diff compares the contents of two files. A filename of - stands for text read from the standard input. As a special case, diff - - compares a copy of standard input to itself.
If <from-file> is a directory and <to-file> is not, diff compares the file in <from-file> whose filename is that of <to-file> and vice versa. The nondirectory file must not be -.
If both <from-file> and <to-file> are directories, diff compares corresponding files in both directories, in alphabetical order; the comparison is not recursive unless -r or -recursive option is specified. diff never compares the actual content of a directory as if it were a file. The file that is fully specified may not be standard input because standard input is nameless and the notion of “file with the same name” does not apply.
Because diff options begin with -, normally <from-file> and <to-file> may not begin with -. However, — as an argument itself treats the remaining arguments as filenames even if they begin with -.
Multiple single-letter options, unless they can take an argument, can be combined into a single command-line word. Long named options can be abbreviated to any unique prefix of their name.
-<lines> Shows <lines> (an integer) lines of context. This option does not specify an output format by itself; it has no effect unless it is combined with -c or -u.
-q  
—brief Reports only whether the files differ, not the details of the differences.
-c Uses the context output format.
-C <lines>  
—context[=<lines>] Uses the context output format, showing <lines> (an integer) lines of context, or 3 if <lines> is not given.
—changed-group-format=
<format>
								

Uses <format> to output a line group containing differing lines from both files in if-then-else format.
-D <name> Makes merged if-then-else format output, conditional on the preprocessor <name>.
-e  
—ed Makes output that is valid ed script.
-x <pattern>  
—exclude=<pattern> When comparing directories, ignores files and subdirectories whose base names match <pattern>.
-X  
—exclude-from=<file> When comparing directories, ignores files and subdirectories whose base names match any pattern contained in <file>.
-t  
—expand-tabs Expands tabs to spaces in the output, to preserve the alignment of tabs in the input files.
-f Makes output that looks vaguely like an ed script but has changes in the order it appears in the file.
-F <regexp> In context and unified format, for each hunk of differences, shows some of the last preceding line that matches <regexp>.
—forward-ed Makes output that looks vaguely like an ed script but has changes in the order it appears in the file.
-h This option has no effect; is present for Unix compatibility.
—help Prints help information.
—horizontal-lines=<lines> Does not discard the last <lines> lines of the common prefix and the first <lines> lines of the common suffix.
-i  
—ignore-case Ignores changes in case; considers uppercase and lowercase letters equivalent.
-I <regexp> Ignores changes that just insert or delete lines that match <regexp>.
—ifdef=<name> Makes merged if-then-else format output, conditional on the preprocessor macro <name>.
-w  
—ignore-all-space Ignores whitespace when comparing lines.
-B  
—ignore-blank-lines Ignores changes that just insert or delete blank lines.
—ignore-matching-lines=
<regexp>.

Ignores changes that just insert or delete lines that match <regexp>
-b  
—ignore-space-change Ignores changes in amount of whitespace.
-T  
—initial-tab Outputs a tab rather than a space before the text of a line in normal or context format. This causes the alignment of tab in the line to look normal.
-L <label>  
—label=<label> Uses <label> instead of the filename in the context format and unified format headers.
—left-column Prints only the left column of the two common lines in side-by-side format.
—line-format=<format> Uses <format> to output all lines in if-then-else format.
-d  
—minimal Changes the algorithm to perhaps find a smaller set of changes. This makes diff slower.
-n  
—rcs Outputs RCS-format diffs; like -f except that each command specifies the number of lines affected.
-N  
—new-file In the directory comparison, if a file is found in only one directory, treats it as present but empty in the other directory.
—new-group-format=<format> Uses <format> to output a group of lines taken from just the second file in if-then-else format.
—new-line-format=<format> Uses <format> to output a line taken from just the second file in if-then-else format.
—old-group-format=<format> Uses <format> to output a group of lines taken from just the first file in if-then-else format.
—old-line-format=<format> Uses <format> to output a line taken from just the first file in if-then-else format.
-p  
—show-c-function Shows which C function each change is in.
-l  
—paginate Passes the output through pr to paginate it.
-r  
—recursive When comparing directories, recursively compares any subdirectories found.
-s  
—report-identical-files Reports when two files are the same.
-S <file>  
—starting-file=<file> When comparing directories, starts with the file <file>. This is used for resuming an aborted comparison.
—sdiff-merge-assist Prints extra information to help sdiff. sdiff uses this option when it runs diff. This option is not intended for users to use directly.
—show-function-line=<regexp> In context and unified format, for each hunk of differences, shows some of the last preceding line that matches <regexp>.
-y  
—side-by-side Uses the side-by-side output format.
-H  
—speed-large-files Uses heuristics to speed handling of large files that have numerous scattered small changes.
—suppress-common-lines Does not print common lines in side-by-side format.
-a  
—text Treats all files as text and compares them line-by-line, even if they do not seem to be text.
-u Uses the unified output format.
-U <lines>  
—unified[=<lines>] Uses the unified output format, showing <lines> (an integer) lines of context, or 3 if <lines> is not given.
—unchanged-group-format=
<format>
								

Uses <format> to output a group of common lines taken <format> from both files in if-then-else format.
—unchanged-line-format=
<format>
								

Uses <format> to output a line common to both files in if- <format> then-else format.
-p  
—undirectional-new-file When comparing directories, if a file appears only in the second directory of the two, treats it as present but empty in the other.
-v  
—version Outputs the version number of diff.
-W <columns>  
—width=<columns> Uses an output width of <columns> in side-by-side format.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint