1 .\" $FreeBSD: src/gnu/usr.bin/diff/diff.1,v 1.6.2.1 2003/02/23 17:49:08 keramida Exp $
2 .TH DIFF 1 "22sep1993" "GNU Tools" "GNU Tools"
4 diff \- find differences between two files
7 [options] from-file to-file
11 compares the contents of the two files
18 text read from the standard input. As a special case,
20 compares a copy of standard input to itself.
30 whose file name is that of
32 and vice versa. The non-directory file must not be
41 compares corresponding files in both directories, in
42 alphabetical order; this comparison is not recursive unless the
49 compares the actual contents of a directory as if it were a file. The
50 file that is fully specified may not be standard input, because standard
51 input is nameless and the notion of ``file with the same name'' does not
66 argument by itself treats the remaining arguments as file names even if
70 Below is a summary of all of the options that GNU
73 Most options have two equivalent names, one of which is a single letter
76 and the other of which is a long name preceded by
78 Multiple single letter options (unless they take an
79 argument) can be combined into a single command line word:
84 Long named options can be abbreviated to
85 any unique prefix of their name. Brackets
90 option takes an optional argument.
95 (an integer) lines of context. This option does not
96 specify an output format by itself; it has no effect unless it is
101 This option is obsolete. For proper
104 typically needs at least two lines of context.
107 Treat all files as text and compare them line-by-line, even if they
108 do not seem to be text.
111 Ignore changes in amount of white space.
114 Ignore changes that just insert or delete blank lines.
117 Report only whether the files differ, not the details of the
121 Use the context output format.
127 .BI \-\-context[= lines ]
128 Use the context output format, showing
130 (an integer) lines of
134 For proper operation,
136 typically needs at least two lines of
139 .BI \-\-changed\-group\-format= format
142 to output a line group containing differing lines from
143 both files in if-then-else format.
144 For more details on what can be specified in the
146 string, consult the info documentation of
150 Change the algorithm to perhaps find a smaller set of changes. This makes
152 slower (sometimes much slower).
155 Make merged if-then-else format output, conditional on the preprocessor
164 Make output that is a valid
168 .BI \-\-exclude= pattern
169 When comparing directories, ignore files and subdirectories whose basenames
173 .BI \-\-exclude\-from= file
174 When comparing directories, ignore files and subdirectories whose basenames
175 match any pattern contained in
179 Expand tabs to spaces in the output, to preserve the alignment of tabs
183 Make output that looks vaguely like an
185 script but has changes
186 in the order they appear in the file.
189 In context and unified format, for each hunk of differences, show some
190 of the last preceding line that matches
194 Make output that looks vaguely like an
196 script but has changes
197 in the order they appear in the file.
200 This option currently has no effect; it is present for Unix
204 Use heuristics to speed handling of large files that have numerous
205 scattered small changes.
207 .BI \-\-horizon\-lines= lines
208 Do not discard the last
210 lines of the common prefix
213 lines of the common suffix.
216 Ignore changes in case; consider upper- and lower-case letters
220 Ignore changes that just insert or delete lines that match
224 Make merged if-then-else format output, conditional on the preprocessor
228 .B \-\-ignore\-all\-space
229 Ignore white space when comparing lines.
231 .B \-\-ignore\-blank\-lines
232 Ignore changes that just insert or delete blank lines.
235 Ignore changes in case; consider upper- and lower-case to be the same.
237 .BI \-\-ignore\-matching\-lines= regexp
238 Ignore changes that just insert or delete lines that match
241 .B \-\-ignore\-space\-change
242 Ignore changes in amount of white space.
245 Output a tab rather than a space before the text of a line in normal or
246 context format. This causes the alignment of tabs in the line to look
250 Pass the output through
261 instead of the file name in the context format
266 Print only the left column of two common lines in side by side format.
268 .BI \-\-line\-format= format
271 to output all input lines in in-then-else format.
274 Change the algorithm to perhaps find a smaller set of changes. This
277 slower (sometimes much slower).
280 Output RCS-format diffs; like
282 except that each command
283 specifies the number of lines affected.
290 In directory comparison, if a file is found in only one directory,
291 treat it as present but empty in the other directory.
293 .BI \-\-new\-group\-format= format
296 to output a group of lines taken from just the second
297 file in if-then-else format.
299 .BI \-\-new\-line\-format= format
302 to output a line taken from just the second file in
306 Use the old traditional output format.
308 .BI \-\-old\-group\-format= format
311 to output a group of lines taken from just the first
312 file in if-then-else format.
314 .BI \-\-old\-line\-format= format
317 to output a line taken from just the first file in
321 Show which C function each change is in.
324 When comparing directories, if a file appears only in the second
325 directory of the two, treat it as present but empty in the other.
328 Pass the output through
333 Report only whether the files differ, not the details of the
337 Output RCS-format diffs; like
339 except that each command
340 specifies the number of lines affected.
347 When comparing directories, recursively compare any subdirectories
354 .B \-\-report\-identical\-files
355 Report when two files are the same.
358 When comparing directories, start with the file
361 used for resuming an aborted comparison.
363 .B \-\-sdiff\-merge\-assist
364 Print extra information to help
370 This option is not intended for users
373 .B \-\-show\-c\-function
374 Show which C function each change is in.
376 .BI \-\-show\-function\-line= regexp
377 In context and unified format, for each hunk of differences, show some
378 of the last preceding line that matches
381 .B \-\-side\-by\-side
382 Use the side by side output format.
384 .B \-\-speed\-large\-files
385 Use heuristics to speed handling of large files that have numerous
386 scattered small changes.
388 .BI \-\-starting\-file= file
389 When comparing directories, start with the file
392 used for resuming an aborted comparison.
394 .B \-\-suppress\-common\-lines
395 Do not print common lines in side by side format.
398 Expand tabs to spaces in the output, to preserve the alignment of tabs
402 Output a tab rather than a space before the text of a line in normal or
403 context format. This causes the alignment of tabs in the line to look
407 Treat all files as text and compare them line-by-line, even if they
408 do not appear to be text.
411 Use the unified output format.
413 .BI \-\-unchanged\-group\-format= format
416 to output a group of common lines taken from both files
417 in if-then-else format.
419 .BI \-\-unchanged\-line\-format= format
422 to output a line common to both files in if-then-else
425 .B \-\-unidirectional\-new\-file
426 When comparing directories, if a file appears only in the second
427 directory of the two, treat it as present but empty in the other.
433 .BI \-\-unified[= lines ]
434 Use the unified output format, showing
436 (an integer) lines of
440 For proper operation,
442 typically needs at least two lines of
450 Output the version number of
454 Ignore horizontal white space when comparing lines.
460 .BI \-\-width= columns
461 Use an output width of
463 in side by side format.
466 When comparing directories, ignore files and subdirectories whose basenames
471 When comparing directories, ignore files and subdirectories whose basenames
472 match any pattern contained in
476 Use the side by side output format.
478 The environment variable
480 can hold a set of default
483 These options are interpreted first and can be overwritten by explicit command
486 To save to a file some changes that you have made to your local source
487 tree (possibly including new files), which you would like to show to others
490 program), you could type
492 diff -crN foo.orig foo >foo.diff
498 might be directory hierarchies or single files.
500 cmp(1), comm(1), diff3(1), ed(1), patch(1), pr(1), sdiff(1).
502 An exit status of 0 means no differences were found, 1 means some
503 differences were found, and 2 means trouble.