1 .\" $FreeBSD: src/gnu/usr.bin/diff/diff.1,v 1.6.2.1 2003/02/23 17:49:08 keramida Exp $
2 .\" $DragonFly: src/gnu/usr.bin/diff/Attic/diff.1,v 1.2 2003/06/17 04:25:45 dillon Exp $
3 .TH DIFF 1 "22sep1993" "GNU Tools" "GNU Tools"
5 diff \- find differences between two files
8 [options] from-file to-file
12 compares the contents of the two files
19 text read from the standard input. As a special case,
21 compares a copy of standard input to itself.
31 whose file name is that of
33 and vice versa. The non-directory file must not be
42 compares corresponding files in both directories, in
43 alphabetical order; this comparison is not recursive unless the
50 compares the actual contents of a directory as if it were a file. The
51 file that is fully specified may not be standard input, because standard
52 input is nameless and the notion of ``file with the same name'' does not
67 argument by itself treats the remaining arguments as file names even if
71 Below is a summary of all of the options that GNU
74 Most options have two equivalent names, one of which is a single letter
77 and the other of which is a long name preceded by
79 Multiple single letter options (unless they take an
80 argument) can be combined into a single command line word:
85 Long named options can be abbreviated to
86 any unique prefix of their name. Brackets
91 option takes an optional argument.
96 (an integer) lines of context. This option does not
97 specify an output format by itself; it has no effect unless it is
102 This option is obsolete. For proper
105 typically needs at least two lines of context.
108 Treat all files as text and compare them line-by-line, even if they
109 do not seem to be text.
112 Ignore changes in amount of white space.
115 Ignore changes that just insert or delete blank lines.
118 Report only whether the files differ, not the details of the
122 Use the context output format.
128 .BI \-\-context[= lines ]
129 Use the context output format, showing
131 (an integer) lines of
135 For proper operation,
137 typically needs at least two lines of
140 .BI \-\-changed\-group\-format= format
143 to output a line group containing differing lines from
144 both files in if-then-else format.
145 For more details on what can be specified in the
147 string, consult the info documentation of
151 Change the algorithm to perhaps find a smaller set of changes. This makes
153 slower (sometimes much slower).
156 Make merged if-then-else format output, conditional on the preprocessor
165 Make output that is a valid
169 .BI \-\-exclude= pattern
170 When comparing directories, ignore files and subdirectories whose basenames
174 .BI \-\-exclude\-from= file
175 When comparing directories, ignore files and subdirectories whose basenames
176 match any pattern contained in
180 Expand tabs to spaces in the output, to preserve the alignment of tabs
184 Make output that looks vaguely like an
186 script but has changes
187 in the order they appear in the file.
190 In context and unified format, for each hunk of differences, show some
191 of the last preceding line that matches
195 Make output that looks vaguely like an
197 script but has changes
198 in the order they appear in the file.
201 This option currently has no effect; it is present for Unix
205 Use heuristics to speed handling of large files that have numerous
206 scattered small changes.
208 .BI \-\-horizon\-lines= lines
209 Do not discard the last
211 lines of the common prefix
214 lines of the common suffix.
217 Ignore changes in case; consider upper- and lower-case letters
221 Ignore changes that just insert or delete lines that match
225 Make merged if-then-else format output, conditional on the preprocessor
229 .B \-\-ignore\-all\-space
230 Ignore white space when comparing lines.
232 .B \-\-ignore\-blank\-lines
233 Ignore changes that just insert or delete blank lines.
236 Ignore changes in case; consider upper- and lower-case to be the same.
238 .BI \-\-ignore\-matching\-lines= regexp
239 Ignore changes that just insert or delete lines that match
242 .B \-\-ignore\-space\-change
243 Ignore changes in amount of white space.
246 Output a tab rather than a space before the text of a line in normal or
247 context format. This causes the alignment of tabs in the line to look
251 Pass the output through
262 instead of the file name in the context format
267 Print only the left column of two common lines in side by side format.
269 .BI \-\-line\-format= format
272 to output all input lines in in-then-else format.
275 Change the algorithm to perhaps find a smaller set of changes. This
278 slower (sometimes much slower).
281 Output RCS-format diffs; like
283 except that each command
284 specifies the number of lines affected.
291 In directory comparison, if a file is found in only one directory,
292 treat it as present but empty in the other directory.
294 .BI \-\-new\-group\-format= format
297 to output a group of lines taken from just the second
298 file in if-then-else format.
300 .BI \-\-new\-line\-format= format
303 to output a line taken from just the second file in
307 Use the old traditional output format.
309 .BI \-\-old\-group\-format= format
312 to output a group of lines taken from just the first
313 file in if-then-else format.
315 .BI \-\-old\-line\-format= format
318 to output a line taken from just the first file in
322 Show which C function each change is in.
325 When comparing directories, if a file appears only in the second
326 directory of the two, treat it as present but empty in the other.
329 Pass the output through
334 Report only whether the files differ, not the details of the
338 Output RCS-format diffs; like
340 except that each command
341 specifies the number of lines affected.
348 When comparing directories, recursively compare any subdirectories
355 .B \-\-report\-identical\-files
356 Report when two files are the same.
359 When comparing directories, start with the file
362 used for resuming an aborted comparison.
364 .B \-\-sdiff\-merge\-assist
365 Print extra information to help
371 This option is not intended for users
374 .B \-\-show\-c\-function
375 Show which C function each change is in.
377 .BI \-\-show\-function\-line= regexp
378 In context and unified format, for each hunk of differences, show some
379 of the last preceding line that matches
382 .B \-\-side\-by\-side
383 Use the side by side output format.
385 .B \-\-speed\-large\-files
386 Use heuristics to speed handling of large files that have numerous
387 scattered small changes.
389 .BI \-\-starting\-file= file
390 When comparing directories, start with the file
393 used for resuming an aborted comparison.
395 .B \-\-suppress\-common\-lines
396 Do not print common lines in side by side format.
399 Expand tabs to spaces in the output, to preserve the alignment of tabs
403 Output a tab rather than a space before the text of a line in normal or
404 context format. This causes the alignment of tabs in the line to look
408 Treat all files as text and compare them line-by-line, even if they
409 do not appear to be text.
412 Use the unified output format.
414 .BI \-\-unchanged\-group\-format= format
417 to output a group of common lines taken from both files
418 in if-then-else format.
420 .BI \-\-unchanged\-line\-format= format
423 to output a line common to both files in if-then-else
426 .B \-\-unidirectional\-new\-file
427 When comparing directories, if a file appears only in the second
428 directory of the two, treat it as present but empty in the other.
434 .BI \-\-unified[= lines ]
435 Use the unified output format, showing
437 (an integer) lines of
441 For proper operation,
443 typically needs at least two lines of
451 Output the version number of
455 Ignore horizontal white space when comparing lines.
461 .BI \-\-width= columns
462 Use an output width of
464 in side by side format.
467 When comparing directories, ignore files and subdirectories whose basenames
472 When comparing directories, ignore files and subdirectories whose basenames
473 match any pattern contained in
477 Use the side by side output format.
479 The environment variable
481 can hold a set of default
484 These options are interpreted first and can be overwritten by explicit command
487 To save to a file some changes that you have made to your local source
488 tree (possibly including new files), which you would like to show to others
491 program), you could type
493 diff -crN foo.orig foo >foo.diff
499 might be directory hierarchies or single files.
501 cmp(1), comm(1), diff3(1), ed(1), patch(1), pr(1), sdiff(1).
503 An exit status of 0 means no differences were found, 1 means some
504 differences were found, and 2 means trouble.