1 This is diff.info, produced by makeinfo version 4.7 from diff.texi.
3 This manual is for GNU Diffutils (version 2.8.7, 12 April 2004), and
4 documents the GNU `diff', `diff3', `sdiff', and `cmp' commands for
5 showing the differences between files and the GNU `patch' command for
6 using their output to update files.
8 Copyright (C) 1992, 1993, 1994, 1998, 2001, 2002, 2004 Free Software
11 Permission is granted to copy, distribute and/or modify this
12 document under the terms of the GNU Free Documentation License,
13 Version 1.1 or any later version published by the Free Software
14 Foundation; with no Invariant Sections, with the Front-Cover texts
15 being "A GNU Manual," and with the Back-Cover Texts as in (a)
16 below. A copy of the license is included in the section entitled
17 "GNU Free Documentation License."
19 (a) The FSF's Back-Cover Text is: "You have freedom to copy and
20 modify this GNU Manual, like GNU software. Copies published by
21 the Free Software Foundation raise funds for GNU development."
23 INFO-DIR-SECTION Individual utilities
25 * cmp: (diff)Invoking cmp. Compare 2 files byte by byte.
26 * diff: (diff)Invoking diff. Compare 2 files line by line.
27 * diff3: (diff)Invoking diff3. Compare 3 files line by line.
28 * patch: (diff)Invoking patch. Apply a patch to a file.
29 * sdiff: (diff)Invoking sdiff. Merge 2 files side-by-side.
32 INFO-DIR-SECTION Text creation and manipulation
34 * Diff: (diff). Comparing and merging files.
38 File: diff.info, Node: Top, Next: Overview, Up: (dir)
40 Comparing and Merging Files
41 ***************************
43 This manual is for GNU Diffutils (version 2.8.7, 12 April 2004), and
44 documents the GNU `diff', `diff3', `sdiff', and `cmp' commands for
45 showing the differences between files and the GNU `patch' command for
46 using their output to update files.
48 Copyright (C) 1992, 1993, 1994, 1998, 2001, 2002, 2004 Free Software
51 Permission is granted to copy, distribute and/or modify this
52 document under the terms of the GNU Free Documentation License,
53 Version 1.1 or any later version published by the Free Software
54 Foundation; with no Invariant Sections, with the Front-Cover texts
55 being "A GNU Manual," and with the Back-Cover Texts as in (a)
56 below. A copy of the license is included in the section entitled
57 "GNU Free Documentation License."
59 (a) The FSF's Back-Cover Text is: "You have freedom to copy and
60 modify this GNU Manual, like GNU software. Copies published by
61 the Free Software Foundation raise funds for GNU development."
65 * Overview:: Preliminary information.
66 * Comparison:: What file comparison means.
68 * Output Formats:: Formats for two-way difference reports.
69 * Incomplete Lines:: Lines that lack trailing newlines.
70 * Comparing Directories:: Comparing files and directories.
71 * Adjusting Output:: Making `diff' output prettier.
72 * diff Performance:: Making `diff' smarter or faster.
74 * Comparing Three Files:: Formats for three-way difference reports.
75 * diff3 Merging:: Merging from a common ancestor.
77 * Interactive Merging:: Interactive merging with `sdiff'.
79 * Merging with patch:: Using `patch' to change old files into new ones.
80 * Making Patches:: Tips for making and using patch distributions.
82 * Invoking cmp:: Compare two files byte by byte.
83 * Invoking diff:: Compare two files line by line.
84 * Invoking diff3:: Compare three files line by line.
85 * Invoking patch:: Apply a diff file to an original.
86 * Invoking sdiff:: Side-by-side merge of file differences.
88 * Standards conformance:: Conformance to the POSIX standard.
89 * Projects:: If you've found a bug or other shortcoming.
91 * Copying This Manual:: How to make copies of this manual.
92 * Translations:: Available translations of this manual.
96 File: diff.info, Node: Overview, Next: Comparison, Prev: Top, Up: Top
101 Computer users often find occasion to ask how two files differ. Perhaps
102 one file is a newer version of the other file. Or maybe the two files
103 started out as identical copies but were changed by different people.
105 You can use the `diff' command to show differences between two
106 files, or each corresponding file in two directories. `diff' outputs
107 differences between files line by line in any of several formats,
108 selectable by command line options. This set of differences is often
109 called a "diff" or "patch". For files that are identical, `diff'
110 normally produces no output; for binary (non-text) files, `diff'
111 normally reports only that they are different.
113 You can use the `cmp' command to show the byte and line numbers
114 where two files differ. `cmp' can also show all the bytes that differ
115 between the two files, side by side. A way to compare two files
116 character by character is the Emacs command `M-x compare-windows'.
117 *Note Other Window: (emacs)Other Window, for more information on that
120 You can use the `diff3' command to show differences among three
121 files. When two people have made independent changes to a common
122 original, `diff3' can report the differences between the original and
123 the two changed versions, and can produce a merged file that contains
124 both persons' changes together with warnings about conflicts.
126 You can use the `sdiff' command to merge two files interactively.
128 You can use the set of differences produced by `diff' to distribute
129 updates to text files (such as program source code) to other people.
130 This method is especially useful when the differences are small compared
131 to the complete files. Given `diff' output, you can use the `patch'
132 program to update, or "patch", a copy of the file. If you think of
133 `diff' as subtracting one file from another to produce their
134 difference, you can think of `patch' as adding the difference to one
135 file to reproduce the other.
137 This manual first concentrates on making diffs, and later shows how
138 to use diffs to update files.
140 GNU `diff' was written by Paul Eggert, Mike Haertel, David Hayes,
141 Richard Stallman, and Len Tower. Wayne Davison designed and
142 implemented the unified output format. The basic algorithm is described
143 by Eugene W. Myers in "An O(ND) Difference Algorithm and its
144 Variations", `Algorithmica' Vol. 1 No. 2, 1986, pp. 251-266; and in "A
145 File Comparison Program", Webb Miller and Eugene W. Myers,
146 `Software--Practice and Experience' Vol. 15 No. 11, 1985, pp. 1025-1040.
147 The algorithm was independently discovered as described by E. Ukkonen in
148 "Algorithms for Approximate String Matching", `Information and Control'
149 Vol. 64, 1985, pp. 100-118. Unless the `--minimal' option is used,
150 `diff' uses a heuristic by Paul Eggert that limits the cost to O(N^1.5
151 log N) at the price of producing suboptimal output for large inputs
152 with many differences. Related algorithms are surveyed by Alfred V.
153 Aho in section 6.3 of "Algorithms for Finding Patterns in Strings",
154 `Handbook of Theoretical Computer Science' (Jan Van Leeuwen, ed.), Vol.
155 A, `Algorithms and Complexity', Elsevier/MIT Press, 1990, pp. 255-300.
157 GNU `diff3' was written by Randy Smith. GNU `sdiff' was written by
158 Thomas Lord. GNU `cmp' was written by Torbjo"rn Granlund and David
161 GNU `patch' was written mainly by Larry Wall and Paul Eggert;
162 several GNU enhancements were contributed by Wayne Davison and David
163 MacKenzie. Parts of this manual are adapted from a manual page written
164 by Larry Wall, with his permission.
167 File: diff.info, Node: Comparison, Next: Output Formats, Prev: Overview, Up: Top
169 1 What Comparison Means
170 ***********************
172 There are several ways to think about the differences between two files.
173 One way to think of the differences is as a series of lines that were
174 deleted from, inserted in, or changed in one file to produce the other
175 file. `diff' compares two files line by line, finds groups of lines
176 that differ, and reports each group of differing lines. It can report
177 the differing lines in several formats, which have different purposes.
179 GNU `diff' can show whether files are different without detailing
180 the differences. It also provides ways to suppress certain kinds of
181 differences that are not important to you. Most commonly, such
182 differences are changes in the amount of white space between words or
183 lines. `diff' also provides ways to suppress differences in alphabetic
184 case or in lines that match a regular expression that you provide.
185 These options can accumulate; for example, you can ignore changes in
186 both white space and alphabetic case.
188 Another way to think of the differences between two files is as a
189 sequence of pairs of bytes that can be either identical or different.
190 `cmp' reports the differences between two files byte by byte, instead
191 of line by line. As a result, it is often more useful than `diff' for
192 comparing binary files. For text files, `cmp' is useful mainly when
193 you want to know only whether two files are identical, or whether one
194 file is a prefix of the other.
196 To illustrate the effect that considering changes byte by byte can
197 have compared with considering them line by line, think of what happens
198 if a single newline character is added to the beginning of a file. If
199 that file is then compared with an otherwise identical file that lacks
200 the newline at the beginning, `diff' will report that a blank line has
201 been added to the file, while `cmp' will report that almost every byte
202 of the two files differs.
204 `diff3' normally compares three input files line by line, finds
205 groups of lines that differ, and reports each group of differing lines.
206 Its output is designed to make it easy to inspect two different sets of
207 changes to the same file.
211 * Hunks:: Groups of differing lines.
212 * White Space:: Suppressing differences in white space.
213 * Blank Lines:: Suppressing differences whose lines are all blank.
214 * Specified Lines:: Suppressing differences whose lines all match a pattern.
215 * Case Folding:: Suppressing differences in alphabetic case.
216 * Brief:: Summarizing which files are different.
217 * Binary:: Comparing binary files or forcing text comparisons.
220 File: diff.info, Node: Hunks, Next: White Space, Up: Comparison
225 When comparing two files, `diff' finds sequences of lines common to
226 both files, interspersed with groups of differing lines called "hunks".
227 Comparing two identical files yields one sequence of common lines and
228 no hunks, because no lines differ. Comparing two entirely different
229 files yields no common lines and one large hunk that contains all lines
230 of both files. In general, there are many ways to match up lines
231 between two given files. `diff' tries to minimize the total hunk size
232 by finding large sequences of common lines interspersed with small
233 hunks of differing lines.
235 For example, suppose the file `F' contains the three lines `a', `b',
236 `c', and the file `G' contains the same three lines in reverse order
237 `c', `b', `a'. If `diff' finds the line `c' as common, then the command
238 `diff F G' produces this output:
247 But if `diff' notices the common line `b' instead, it produces this
259 It is also possible to find `a' as the common line. `diff' does not
260 always find an optimal matching between the files; it takes shortcuts
261 to run faster. But its output is usually close to the shortest
262 possible. You can adjust this tradeoff with the `-d' or `--minimal'
263 option (*note diff Performance::).
266 File: diff.info, Node: White Space, Next: Blank Lines, Prev: Hunks, Up: Comparison
268 1.2 Suppressing Differences in Blank and Tab Spacing
269 ====================================================
271 The `-E' or `--ignore-tab-expansion' option ignores the distinction
272 between tabs and spaces on input. A tab is considered to be equivalent
273 to the number of spaces to the next tab stop (*note Tabs::).
275 The `-b' or `--ignore-space-change' option is stronger. It ignores
276 white space at line end, and considers all other sequences of one or
277 more white space characters within a line to be equivalent. With this
278 option, `diff' considers the following two lines to be equivalent,
279 where `$' denotes the line end:
281 Here lyeth muche rychnesse in lytell space. -- John Heywood$
282 Here lyeth muche rychnesse in lytell space. -- John Heywood $
284 The `-w' or `--ignore-all-space' option is stronger still. It
285 ignores differences even if one line has white space where the other
286 line has none. "White space" characters include tab, newline, vertical
287 tab, form feed, carriage return, and space; some locales may define
288 additional characters to be white space. With this option, `diff'
289 considers the following two lines to be equivalent, where `$' denotes
290 the line end and `^M' denotes a carriage return:
292 Here lyeth muche rychnesse in lytell space.-- John Heywood$
293 He relyeth much erychnes seinly tells pace. --John Heywood ^M$
296 File: diff.info, Node: Blank Lines, Next: Specified Lines, Prev: White Space, Up: Comparison
298 1.3 Suppressing Differences Whose Lines Are All Blank
299 =====================================================
301 The `-B' or `--ignore-blank-lines' option ignores changes that consist
302 entirely of blank lines. With this option, for example, a file
304 1. A point is that which has no part.
306 2. A line is breadthless length.
307 -- Euclid, The Elements, I
308 is considered identical to a file containing
309 1. A point is that which has no part.
310 2. A line is breadthless length.
313 -- Euclid, The Elements, I
315 Normally this option affects only lines that are completely empty,
316 but if you also specify the `-b' or `--ignore-space-change' option, or
317 the `-w' or `--ignore-all-space' option, lines are also affected if
318 they look empty but contain white space. In other words, `-B' is
319 equivalent to `-I '^$'' by default, but it is equivalent to `-I
320 '^[[:space:]]*$'' if `-b' or `-w' is also specified.
323 File: diff.info, Node: Specified Lines, Next: Case Folding, Prev: Blank Lines, Up: Comparison
325 1.4 Suppressing Differences Whose Lines All Match a Regular Expression
326 ======================================================================
328 To ignore insertions and deletions of lines that match a `grep'-style
329 regular expression, use the `-I REGEXP' or
330 `--ignore-matching-lines=REGEXP' option. You should escape regular
331 expressions that contain shell metacharacters to prevent the shell from
332 expanding them. For example, `diff -I '^[[:digit:]]'' ignores all
333 changes to lines beginning with a digit.
335 However, `-I' only ignores the insertion or deletion of lines that
336 contain the regular expression if every changed line in the hunk--every
337 insertion and every deletion--matches the regular expression. In other
338 words, for each nonignorable change, `diff' prints the complete set of
339 changes in its vicinity, including the ignorable ones.
341 You can specify more than one regular expression for lines to ignore
342 by using more than one `-I' option. `diff' tries to match each line
343 against each regular expression.
346 File: diff.info, Node: Case Folding, Next: Brief, Prev: Specified Lines, Up: Comparison
348 1.5 Suppressing Case Differences
349 ================================
351 GNU `diff' can treat lower case letters as equivalent to their upper
352 case counterparts, so that, for example, it considers `Funky Stuff',
353 `funky STUFF', and `fUNKy stuFf' to all be the same. To request this,
354 use the `-i' or `--ignore-case' option.
357 File: diff.info, Node: Brief, Next: Binary, Prev: Case Folding, Up: Comparison
359 1.6 Summarizing Which Files Differ
360 ==================================
362 When you only want to find out whether files are different, and you
363 don't care what the differences are, you can use the summary output
364 format. In this format, instead of showing the differences between the
365 files, `diff' simply reports whether files differ. The `-q' or
366 `--brief' option selects this output format.
368 This format is especially useful when comparing the contents of two
369 directories. It is also much faster than doing the normal line by line
370 comparisons, because `diff' can stop analyzing the files as soon as it
371 knows that there are any differences.
373 You can also get a brief indication of whether two files differ by
374 using `cmp'. For files that are identical, `cmp' produces no output.
375 When the files differ, by default, `cmp' outputs the byte and line
376 number where the first difference occurs, or reports that one file is a
377 prefix of the other. You can use the `-s', `--quiet', or `--silent'
378 option to suppress that information, so that `cmp' produces no output
379 and reports whether the files differ using only its exit status (*note
382 Unlike `diff', `cmp' cannot compare directories; it can only compare
386 File: diff.info, Node: Binary, Prev: Brief, Up: Comparison
388 1.7 Binary Files and Forcing Text Comparisons
389 =============================================
391 If `diff' thinks that either of the two files it is comparing is binary
392 (a non-text file), it normally treats that pair of files much as if the
393 summary output format had been selected (*note Brief::), and reports
394 only that the binary files are different. This is because line by line
395 comparisons are usually not meaningful for binary files.
397 `diff' determines whether a file is text or binary by checking the
398 first few bytes in the file; the exact number of bytes is system
399 dependent, but it is typically several thousand. If every byte in that
400 part of the file is non-null, `diff' considers the file to be text;
401 otherwise it considers the file to be binary.
403 Sometimes you might want to force `diff' to consider files to be
404 text. For example, you might be comparing text files that contain null
405 characters; `diff' would erroneously decide that those are non-text
406 files. Or you might be comparing documents that are in a format used
407 by a word processing system that uses null characters to indicate
408 special formatting. You can force `diff' to consider all files to be
409 text files, and compare them line by line, by using the `-a' or
410 `--text' option. If the files you compare using this option do not in
411 fact contain text, they will probably contain few newline characters,
412 and the `diff' output will consist of hunks showing differences between
413 long lines of whatever characters the files contain.
415 You can also force `diff' to report only whether files differ (but
416 not how). Use the `-q' or `--brief' option for this.
418 Normally, differing binary files count as trouble because the
419 resulting `diff' output does not capture all the differences. This
420 trouble causes `diff' to exit with status 2. However, this trouble
421 cannot occur with the `-a' or `--text' option, or with the `-q' or
422 `--brief' option, as these options both cause `diff' to generate a form
423 of output that represents differences as requested.
425 In operating systems that distinguish between text and binary files,
426 `diff' normally reads and writes all data as text. Use the `--binary'
427 option to force `diff' to read and write binary data instead. This
428 option has no effect on a POSIX-compliant system like GNU or
429 traditional Unix. However, many personal computer operating systems
430 represent the end of a line with a carriage return followed by a
431 newline. On such systems, `diff' normally ignores these carriage
432 returns on input and generates them at the end of each output line, but
433 with the `--binary' option `diff' treats each carriage return as just
434 another input character, and does not generate a carriage return at the
435 end of each output line. This can be useful when dealing with non-text
436 files that are meant to be interchanged with POSIX-compliant systems.
438 The `--strip-trailing-cr' causes `diff' to treat input lines that
439 end in carriage return followed by newline as if they end in plain
440 newline. This can be useful when comparing text that is imperfectly
441 imported from many personal computer operating systems. This option
442 affects how lines are read, which in turn affects how they are compared
445 If you want to compare two files byte by byte, you can use the `cmp'
446 program with the `-l' or `--verbose' option to show the values of each
447 differing byte in the two files. With GNU `cmp', you can also use the
448 `-b' or `--print-bytes' option to show the ASCII representation of
449 those bytes. *Note Invoking cmp::, for more information.
451 If `diff3' thinks that any of the files it is comparing is binary (a
452 non-text file), it normally reports an error, because such comparisons
453 are usually not useful. `diff3' uses the same test as `diff' to decide
454 whether a file is binary. As with `diff', if the input files contain a
455 few non-text bytes but otherwise are like text files, you can force
456 `diff3' to consider all files to be text files and compare them line by
457 line by using the `-a' or `--text' option.
460 File: diff.info, Node: Output Formats, Next: Incomplete Lines, Prev: Comparison, Up: Top
462 2 `diff' Output Formats
463 ***********************
465 `diff' has several mutually exclusive options for output format. The
466 following sections describe each format, illustrating how `diff'
467 reports the differences between two sample input files.
471 * Sample diff Input:: Sample `diff' input files for examples.
472 * Context:: Showing differences with the surrounding text.
473 * Side by Side:: Showing differences in two columns.
474 * Normal:: Showing differences without surrounding text.
475 * Scripts:: Generating scripts for other programs.
476 * If-then-else:: Merging files with if-then-else.
479 File: diff.info, Node: Sample diff Input, Next: Context, Up: Output Formats
481 2.1 Two Sample Input Files
482 ==========================
484 Here are two sample files that we will use in numerous examples to
485 illustrate the output of `diff' and how various options can change it.
487 This is the file `lao':
489 The Way that can be told of is not the eternal Way;
490 The name that can be named is not the eternal name.
491 The Nameless is the origin of Heaven and Earth;
492 The Named is the mother of all things.
493 Therefore let there always be non-being,
494 so we may see their subtlety,
495 And let there always be being,
496 so we may see their outcome.
497 The two are the same,
498 But after they are produced,
499 they have different names.
501 This is the file `tzu':
503 The Nameless is the origin of Heaven and Earth;
504 The named is the mother of all things.
506 Therefore let there always be non-being,
507 so we may see their subtlety,
508 And let there always be being,
509 so we may see their outcome.
510 The two are the same,
511 But after they are produced,
512 they have different names.
513 They both may be called deep and profound.
514 Deeper and more profound,
515 The door of all subtleties!
517 In this example, the first hunk contains just the first two lines of
518 `lao', the second hunk contains the fourth line of `lao' opposing the
519 second and third lines of `tzu', and the last hunk contains just the
520 last three lines of `tzu'.
523 File: diff.info, Node: Context, Next: Side by Side, Prev: Sample diff Input, Up: Output Formats
525 2.2 Showing Differences in Their Context
526 ========================================
528 Usually, when you are looking at the differences between files, you will
529 also want to see the parts of the files near the lines that differ, to
530 help you understand exactly what has changed. These nearby parts of the
531 files are called the "context".
533 GNU `diff' provides two output formats that show context around the
534 differing lines: "context format" and "unified format". It can
535 optionally show in which function or section of the file the differing
538 If you are distributing new versions of files to other people in the
539 form of `diff' output, you should use one of the output formats that
540 show context so that they can apply the diffs even if they have made
541 small changes of their own to the files. `patch' can apply the diffs
542 in this case by searching in the files for the lines of context around
543 the differing lines; if those lines are actually a few lines away from
544 where the diff says they are, `patch' can adjust the line numbers
545 accordingly and still apply the diff correctly. *Note Imperfect::, for
546 more information on using `patch' to apply imperfect diffs.
550 * Context Format:: An output format that shows surrounding lines.
551 * Unified Format:: A more compact output format that shows context.
552 * Sections:: Showing which sections of the files differences are in.
553 * Alternate Names:: Showing alternate file names in context headers.
556 File: diff.info, Node: Context Format, Next: Unified Format, Up: Context
561 The context output format shows several lines of context around the
562 lines that differ. It is the standard format for distributing updates
565 To select this output format, use the `-C LINES',
566 `--context[=LINES]', or `-c' option. The argument LINES that some of
567 these options take is the number of lines of context to show. If you
568 do not specify LINES, it defaults to three. For proper operation,
569 `patch' typically needs at least two lines of context.
573 * Example Context:: Sample output in context format.
574 * Less Context:: Another sample with less context.
575 * Detailed Context:: A detailed description of the context output format.
578 File: diff.info, Node: Example Context, Next: Less Context, Up: Context Format
580 2.2.1.1 An Example of Context Format
581 ....................................
583 Here is the output of `diff -c lao tzu' (*note Sample diff Input::, for
584 the complete contents of the two files). Notice that up to three lines
585 that are not different are shown around each line that is different;
586 they are the context lines. Also notice that the first two hunks have
587 run together, because their contents overlap.
589 *** lao 2002-02-21 23:30:39.942229878 -0800
590 --- tzu 2002-02-21 23:30:50.442260588 -0800
593 - The Way that can be told of is not the eternal Way;
594 - The name that can be named is not the eternal name.
595 The Nameless is the origin of Heaven and Earth;
596 ! The Named is the mother of all things.
597 Therefore let there always be non-being,
598 so we may see their subtlety,
599 And let there always be being,
601 The Nameless is the origin of Heaven and Earth;
602 ! The named is the mother of all things.
604 Therefore let there always be non-being,
605 so we may see their subtlety,
606 And let there always be being,
610 The two are the same,
611 But after they are produced,
612 they have different names.
613 + They both may be called deep and profound.
614 + Deeper and more profound,
615 + The door of all subtleties!
618 File: diff.info, Node: Less Context, Next: Detailed Context, Prev: Example Context, Up: Context Format
620 2.2.1.2 An Example of Context Format with Less Context
621 ......................................................
623 Here is the output of `diff -C 1 lao tzu' (*note Sample diff Input::,
624 for the complete contents of the two files). Notice that at most one
625 context line is reported here.
627 *** lao 2002-02-21 23:30:39.942229878 -0800
628 --- tzu 2002-02-21 23:30:50.442260588 -0800
631 - The Way that can be told of is not the eternal Way;
632 - The name that can be named is not the eternal name.
633 The Nameless is the origin of Heaven and Earth;
634 ! The Named is the mother of all things.
635 Therefore let there always be non-being,
637 The Nameless is the origin of Heaven and Earth;
638 ! The named is the mother of all things.
640 Therefore let there always be non-being,
644 they have different names.
645 + They both may be called deep and profound.
646 + Deeper and more profound,
647 + The door of all subtleties!
650 File: diff.info, Node: Detailed Context, Prev: Less Context, Up: Context Format
652 2.2.1.3 Detailed Description of Context Format
653 ..............................................
655 The context output format starts with a two-line header, which looks
658 *** FROM-FILE FROM-FILE-MODIFICATION-TIME
659 --- TO-FILE TO-FILE-MODIFICATION TIME
661 The time stamp normally looks like `2002-02-21 23:30:39.942229878
662 -0800' to indicate the date, time with fractional seconds, and time
663 zone in Internet RFC 2822 format
664 (ftp://ftp.isi.edu/in-notes/rfc2822.txt). (The fractional seconds are
665 omitted on hosts that do not support fractional time stamps.) However,
666 a traditional time stamp like `Thu Feb 21 23:30:39 2002' is used if the
667 `LC_TIME' locale category is either `C' or `POSIX'.
669 You can change the header's content with the `--label=LABEL' option;
670 see *Note Alternate Names::.
672 Next come one or more hunks of differences; each hunk shows one area
673 where the files differ. Context format hunks look like this:
676 *** FROM-FILE-LINE-NUMBERS ****
679 --- TO-FILE-LINE-NUMBERS ----
683 If a hunk contains two or more lines, its line numbers look like
684 `START,END'. Otherwise only its end line number appears. An empty
685 hunk is considered to end at the line that precedes the hunk.
687 The lines of context around the lines that differ start with two
688 space characters. The lines that differ between the two files start
689 with one of the following indicator characters, followed by a space
693 A line that is part of a group of one or more lines that changed
694 between the two files. There is a corresponding group of lines
695 marked with `!' in the part of this hunk for the other file.
698 An "inserted" line in the second file that corresponds to nothing
702 A "deleted" line in the first file that corresponds to nothing in
705 If all of the changes in a hunk are insertions, the lines of
706 FROM-FILE are omitted. If all of the changes are deletions, the lines
707 of TO-FILE are omitted.
710 File: diff.info, Node: Unified Format, Next: Sections, Prev: Context Format, Up: Context
715 The unified output format is a variation on the context format that is
716 more compact because it omits redundant context lines. To select this
717 output format, use the `-U LINES', `--unified[=LINES]', or `-u' option.
718 The argument LINES is the number of lines of context to show. When it
719 is not given, it defaults to three.
721 At present, only GNU `diff' can produce this format and only GNU
722 `patch' can automatically apply diffs in this format. For proper
723 operation, `patch' typically needs at least three lines of context.
727 * Example Unified:: Sample output in unified format.
728 * Detailed Unified:: A detailed description of unified format.
731 File: diff.info, Node: Example Unified, Next: Detailed Unified, Up: Unified Format
733 2.2.2.1 An Example of Unified Format
734 ....................................
736 Here is the output of the command `diff -u lao tzu' (*note Sample diff
737 Input::, for the complete contents of the two files):
739 --- lao 2002-02-21 23:30:39.942229878 -0800
740 +++ tzu 2002-02-21 23:30:50.442260588 -0800
742 -The Way that can be told of is not the eternal Way;
743 -The name that can be named is not the eternal name.
744 The Nameless is the origin of Heaven and Earth;
745 -The Named is the mother of all things.
746 +The named is the mother of all things.
748 Therefore let there always be non-being,
749 so we may see their subtlety,
750 And let there always be being,
752 The two are the same,
753 But after they are produced,
754 they have different names.
755 +They both may be called deep and profound.
756 +Deeper and more profound,
757 +The door of all subtleties!
760 File: diff.info, Node: Detailed Unified, Prev: Example Unified, Up: Unified Format
762 2.2.2.2 Detailed Description of Unified Format
763 ..............................................
765 The unified output format starts with a two-line header, which looks
768 --- FROM-FILE FROM-FILE-MODIFICATION-TIME
769 +++ TO-FILE TO-FILE-MODIFICATION-TIME
771 The time stamp looks like `2002-02-21 23:30:39.942229878 -0800' to
772 indicate the date, time with fractional seconds, and time zone. The
773 fractional seconds are omitted on hosts that do not support fractional
776 You can change the header's content with the `--label=LABEL' option;
777 see *Note Alternate Names::.
779 Next come one or more hunks of differences; each hunk shows one area
780 where the files differ. Unified format hunks look like this:
782 @@ FROM-FILE-LINE-NUMBERS TO-FILE-LINE-NUMBERS @@
783 LINE-FROM-EITHER-FILE
784 LINE-FROM-EITHER-FILE...
786 If a hunk contains just one line, only its start line number appears.
787 Otherwise its line numbers look like `START,COUNT'. An empty hunk is
788 considered to start at the line that follows the hunk.
790 If a hunk and its context contain two or more lines, its line
791 numbers look like `START,COUNT'. Otherwise only its end line number
792 appears. An empty hunk is considered to end at the line that precedes
795 The lines common to both files begin with a space character. The
796 lines that actually differ between the two files have one of the
797 following indicator characters in the left print column:
800 A line was added here to the first file.
803 A line was removed here from the first file.
806 File: diff.info, Node: Sections, Next: Alternate Names, Prev: Unified Format, Up: Context
808 2.2.3 Showing Which Sections Differences Are in
809 -----------------------------------------------
811 Sometimes you might want to know which part of the files each change
812 falls in. If the files are source code, this could mean which function
813 was changed. If the files are documents, it could mean which chapter
814 or appendix was changed. GNU `diff' can show this by displaying the
815 nearest section heading line that precedes the differing lines. Which
816 lines are "section headings" is determined by a regular expression.
820 * Specified Headings:: Showing headings that match regular expressions.
821 * C Function Headings:: Showing headings of C functions.
824 File: diff.info, Node: Specified Headings, Next: C Function Headings, Up: Sections
826 2.2.3.1 Showing Lines That Match Regular Expressions
827 ....................................................
829 To show in which sections differences occur for files that are not
830 source code for C or similar languages, use the `-F REGEXP' or
831 `--show-function-line=REGEXP' option. `diff' considers lines that
832 match the `grep'-style regular expression REGEXP to be the beginning of
833 a section of the file. Here are suggested regular expressions for some
845 This option does not automatically select an output format; in order
846 to use it, you must select the context format (*note Context Format::)
847 or unified format (*note Unified Format::). In other output formats it
850 The `-F' or `--show-function-line' option finds the nearest
851 unchanged line that precedes each hunk of differences and matches the
852 given regular expression. Then it adds that line to the end of the
853 line of asterisks in the context format, or to the `@@' line in unified
854 format. If no matching line exists, this option leaves the output for
855 that hunk unchanged. If that line is more than 40 characters long, it
856 outputs only the first 40 characters. You can specify more than one
857 regular expression for such lines; `diff' tries to match each line
858 against each regular expression, starting with the last one given. This
859 means that you can use `-p' and `-F' together, if you wish.
862 File: diff.info, Node: C Function Headings, Prev: Specified Headings, Up: Sections
864 2.2.3.2 Showing C Function Headings
865 ...................................
867 To show in which functions differences occur for C and similar
868 languages, you can use the `-p' or `--show-c-function' option. This
869 option automatically defaults to the context output format (*note
870 Context Format::), with the default number of lines of context. You
871 can override that number with `-C LINES' elsewhere in the command line.
872 You can override both the format and the number with `-U LINES'
873 elsewhere in the command line.
875 The `-p' or `--show-c-function' option is equivalent to `-F
876 '^[[:alpha:]$_]'' if the unified format is specified, otherwise `-c -F
877 '^[[:alpha:]$_]'' (*note Specified Headings::). GNU `diff' provides
878 this option for the sake of convenience.
881 File: diff.info, Node: Alternate Names, Prev: Sections, Up: Context
883 2.2.4 Showing Alternate File Names
884 ----------------------------------
886 If you are comparing two files that have meaningless or uninformative
887 names, you might want `diff' to show alternate names in the header of
888 the context and unified output formats. To do this, use the
889 `--label=LABEL' option. The first time you give this option, its
890 argument replaces the name and date of the first file in the header;
891 the second time, its argument replaces the name and date of the second
892 file. If you give this option more than twice, `diff' reports an
893 error. The `--label' option does not affect the file names in the `pr'
894 header when the `-l' or `--paginate' option is used (*note
897 Here are the first two lines of the output from `diff -C 2
898 --label=original --label=modified lao tzu':
904 File: diff.info, Node: Side by Side, Next: Normal, Prev: Context, Up: Output Formats
906 2.3 Showing Differences Side by Side
907 ====================================
909 `diff' can produce a side by side difference listing of two files. The
910 files are listed in two columns with a gutter between them. The gutter
911 contains one of the following markers:
914 The corresponding lines are in common. That is, either the lines
915 are identical, or the difference is ignored because of one of the
916 `--ignore' options (*note White Space::).
919 The corresponding lines differ, and they are either both complete
923 The files differ and only the first file contains the line.
926 The files differ and only the second file contains the line.
929 Only the first file contains the line, but the difference is
933 Only the second file contains the line, but the difference is
937 The corresponding lines differ, and only the first line is
941 The corresponding lines differ, and only the second line is
944 Normally, an output line is incomplete if and only if the lines that
945 it contains are incomplete; *Note Incomplete Lines::. However, when an
946 output line represents two differing lines, one might be incomplete
947 while the other is not. In this case, the output line is complete, but
948 its the gutter is marked `\' if the first line is incomplete, `/' if
951 Side by side format is sometimes easiest to read, but it has
952 limitations. It generates much wider output than usual, and truncates
953 lines that are too long to fit. Also, it relies on lining up output
954 more heavily than usual, so its output looks particularly bad if you
955 use varying width fonts, nonstandard tab stops, or nonprinting
958 You can use the `sdiff' command to interactively merge side by side
959 differences. *Note Interactive Merging::, for more information on
964 * Side by Side Format:: Controlling side by side output format.
965 * Example Side by Side:: Sample side by side output.
968 File: diff.info, Node: Side by Side Format, Next: Example Side by Side, Up: Side by Side
970 2.3.1 Controlling Side by Side Format
971 -------------------------------------
973 The `-y' or `--side-by-side' option selects side by side format.
974 Because side by side output lines contain two input lines, the output
975 is wider than usual: normally 130 print columns, which can fit onto a
976 traditional printer line. You can set the width of the output with the
977 `-W COLUMNS' or `--width=COLUMNS' option. The output is split into two
978 halves of equal width, separated by a small gutter to mark differences;
979 the right half is aligned to a tab stop so that tabs line up. Input
980 lines that are too long to fit in half of an output line are truncated
983 The `--left-column' option prints only the left column of two common
984 lines. The `--suppress-common-lines' option suppresses common lines
988 File: diff.info, Node: Example Side by Side, Prev: Side by Side Format, Up: Side by Side
990 2.3.2 An Example of Side by Side Format
991 ---------------------------------------
993 Here is the output of the command `diff -y -W 72 lao tzu' (*note Sample
994 diff Input::, for the complete contents of the two files).
996 The Way that can be told of is n <
997 The name that can be named is no <
998 The Nameless is the origin of He The Nameless is the origin of He
999 The Named is the mother of all t | The named is the mother of all t
1001 Therefore let there always be no Therefore let there always be no
1002 so we may see their subtlety, so we may see their subtlety,
1003 And let there always be being, And let there always be being,
1004 so we may see their outcome. so we may see their outcome.
1005 The two are the same, The two are the same,
1006 But after they are produced, But after they are produced,
1007 they have different names. they have different names.
1008 > They both may be called deep and
1009 > Deeper and more profound,
1010 > The door of all subtleties!
1013 File: diff.info, Node: Normal, Next: Scripts, Prev: Side by Side, Up: Output Formats
1015 2.4 Showing Differences Without Context
1016 =======================================
1018 The "normal" `diff' output format shows each hunk of differences
1019 without any surrounding context. Sometimes such output is the clearest
1020 way to see how lines have changed, without the clutter of nearby
1021 unchanged lines (although you can get similar results with the context
1022 or unified formats by using 0 lines of context). However, this format
1023 is no longer widely used for sending out patches; for that purpose, the
1024 context format (*note Context Format::) and the unified format (*note
1025 Unified Format::) are superior. Normal format is the default for
1026 compatibility with older versions of `diff' and the POSIX standard.
1027 Use the `--normal' option to select this output format explicitly.
1031 * Example Normal:: Sample output in the normal format.
1032 * Detailed Normal:: A detailed description of normal output format.
1035 File: diff.info, Node: Example Normal, Next: Detailed Normal, Up: Normal
1037 2.4.1 An Example of Normal Format
1038 ---------------------------------
1040 Here is the output of the command `diff lao tzu' (*note Sample diff
1041 Input::, for the complete contents of the two files). Notice that it
1042 shows only the lines that are different between the two files.
1045 < The Way that can be told of is not the eternal Way;
1046 < The name that can be named is not the eternal name.
1048 < The Named is the mother of all things.
1050 > The named is the mother of all things.
1053 > They both may be called deep and profound.
1054 > Deeper and more profound,
1055 > The door of all subtleties!
1058 File: diff.info, Node: Detailed Normal, Prev: Example Normal, Up: Normal
1060 2.4.2 Detailed Description of Normal Format
1061 -------------------------------------------
1063 The normal output format consists of one or more hunks of differences;
1064 each hunk shows one area where the files differ. Normal format hunks
1074 There are three types of change commands. Each consists of a line
1075 number or comma-separated range of lines in the first file, a single
1076 character indicating the kind of change to make, and a line number or
1077 comma-separated range of lines in the second file. All line numbers are
1078 the original line numbers in each file. The types of change commands
1082 Add the lines in range R of the second file after line L of the
1083 first file. For example, `8a12,15' means append lines 12-15 of
1084 file 2 after line 8 of file 1; or, if changing file 2 into file 1,
1085 delete lines 12-15 of file 2.
1088 Replace the lines in range F of the first file with lines in range
1089 T of the second file. This is like a combined add and delete, but
1090 more compact. For example, `5,7c8,10' means change lines 5-7 of
1091 file 1 to read as lines 8-10 of file 2; or, if changing file 2 into
1092 file 1, change lines 8-10 of file 2 to read as lines 5-7 of file 1.
1095 Delete the lines in range R from the first file; line L is where
1096 they would have appeared in the second file had they not been
1097 deleted. For example, `5,7d3' means delete lines 5-7 of file 1;
1098 or, if changing file 2 into file 1, append lines 5-7 of file 1
1099 after line 3 of file 2.
1102 File: diff.info, Node: Scripts, Next: If-then-else, Prev: Normal, Up: Output Formats
1104 2.5 Making Edit Scripts
1105 =======================
1107 Several output modes produce command scripts for editing FROM-FILE to
1112 * ed Scripts:: Using `diff' to produce commands for `ed'.
1113 * Forward ed:: Making forward `ed' scripts.
1114 * RCS:: A special `diff' output format used by RCS.
1117 File: diff.info, Node: ed Scripts, Next: Forward ed, Up: Scripts
1122 `diff' can produce commands that direct the `ed' text editor to change
1123 the first file into the second file. Long ago, this was the only
1124 output mode that was suitable for editing one file into another
1125 automatically; today, with `patch', it is almost obsolete. Use the
1126 `-e' or `--ed' option to select this output format.
1128 Like the normal format (*note Normal::), this output format does not
1129 show any context; unlike the normal format, it does not include the
1130 information necessary to apply the diff in reverse (to produce the first
1131 file if all you have is the second file and the diff).
1133 If the file `d' contains the output of `diff -e old new', then the
1134 command `(cat d && echo w) | ed - old' edits `old' to make it a copy of
1135 `new'. More generally, if `d1', `d2', ..., `dN' contain the outputs of
1136 `diff -e old new1', `diff -e new1 new2', ..., `diff -e newN-1 newN',
1137 respectively, then the command `(cat d1 d2 ... dN && echo w) | ed -
1138 old' edits `old' to make it a copy of `newN'.
1142 * Example ed:: A sample `ed' script.
1143 * Detailed ed:: A detailed description of `ed' format.
1146 File: diff.info, Node: Example ed, Next: Detailed ed, Up: ed Scripts
1148 2.5.1.1 Example `ed' Script
1149 ...........................
1151 Here is the output of `diff -e lao tzu' (*note Sample diff Input::, for
1152 the complete contents of the two files):
1155 They both may be called deep and profound.
1156 Deeper and more profound,
1157 The door of all subtleties!
1160 The named is the mother of all things.
1166 File: diff.info, Node: Detailed ed, Prev: Example ed, Up: ed Scripts
1168 2.5.1.2 Detailed Description of `ed' Format
1169 ...........................................
1171 The `ed' output format consists of one or more hunks of differences.
1172 The changes closest to the ends of the files come first so that
1173 commands that change the number of lines do not affect how `ed'
1174 interprets line numbers in succeeding commands. `ed' format hunks look
1182 Because `ed' uses a single period on a line to indicate the end of
1183 input, GNU `diff' protects lines of changes that contain a single
1184 period on a line by writing two periods instead, then writing a
1185 subsequent `ed' command to change the two periods into one. The `ed'
1186 format cannot represent an incomplete line, so if the second file ends
1187 in a changed incomplete line, `diff' reports an error and then pretends
1188 that a newline was appended.
1190 There are three types of change commands. Each consists of a line
1191 number or comma-separated range of lines in the first file and a single
1192 character indicating the kind of change to make. All line numbers are
1193 the original line numbers in the file. The types of change commands
1197 Add text from the second file after line L in the first file. For
1198 example, `8a' means to add the following lines after line 8 of file
1202 Replace the lines in range R in the first file with the following
1203 lines. Like a combined add and delete, but more compact. For
1204 example, `5,7c' means change lines 5-7 of file 1 to read as the
1208 Delete the lines in range R from the first file. For example,
1209 `5,7d' means delete lines 5-7 of file 1.
1212 File: diff.info, Node: Forward ed, Next: RCS, Prev: ed Scripts, Up: Scripts
1214 2.5.2 Forward `ed' Scripts
1215 --------------------------
1217 `diff' can produce output that is like an `ed' script, but with hunks
1218 in forward (front to back) order. The format of the commands is also
1219 changed slightly: command characters precede the lines they modify,
1220 spaces separate line numbers in ranges, and no attempt is made to
1221 disambiguate hunk lines consisting of a single period. Like `ed'
1222 format, forward `ed' format cannot represent incomplete lines.
1224 Forward `ed' format is not very useful, because neither `ed' nor
1225 `patch' can apply diffs in this format. It exists mainly for
1226 compatibility with older versions of `diff'. Use the `-f' or
1227 `--forward-ed' option to select it.
1230 File: diff.info, Node: RCS, Prev: Forward ed, Up: Scripts
1235 The RCS output format is designed specifically for use by the Revision
1236 Control System, which is a set of free programs used for organizing
1237 different versions and systems of files. Use the `-n' or `--rcs'
1238 option to select this output format. It is like the forward `ed'
1239 format (*note Forward ed::), but it can represent arbitrary changes to
1240 the contents of a file because it avoids the forward `ed' format's
1241 problems with lines consisting of a single period and with incomplete
1242 lines. Instead of ending text sections with a line consisting of a
1243 single period, each command specifies the number of lines it affects; a
1244 combination of the `a' and `d' commands are used instead of `c'. Also,
1245 if the second file ends in a changed incomplete line, then the output
1246 also ends in an incomplete line.
1248 Here is the output of `diff -n lao tzu' (*note Sample diff Input::,
1249 for the complete contents of the two files):
1254 The named is the mother of all things.
1257 They both may be called deep and profound.
1258 Deeper and more profound,
1259 The door of all subtleties!
1262 File: diff.info, Node: If-then-else, Prev: Scripts, Up: Output Formats
1264 2.6 Merging Files with If-then-else
1265 ===================================
1267 You can use `diff' to merge two files of C source code. The output of
1268 `diff' in this format contains all the lines of both files. Lines
1269 common to both files are output just once; the differing parts are
1270 separated by the C preprocessor directives `#ifdef NAME' or `#ifndef
1271 NAME', `#else', and `#endif'. When compiling the output, you select
1272 which version to use by either defining or leaving undefined the macro
1275 To merge two files, use `diff' with the `-D NAME' or `--ifdef=NAME'
1276 option. The argument NAME is the C preprocessor identifier to use in
1277 the `#ifdef' and `#ifndef' directives.
1279 For example, if you change an instance of `wait (&s)' to `waitpid
1280 (-1, &s, 0)' and then merge the old and new files with the
1281 `--ifdef=HAVE_WAITPID' option, then the affected part of your code
1282 might look like this:
1285 #ifndef HAVE_WAITPID
1286 if ((w = wait (&s)) < 0 && errno != EINTR)
1287 #else /* HAVE_WAITPID */
1288 if ((w = waitpid (-1, &s, 0)) < 0 && errno != EINTR)
1289 #endif /* HAVE_WAITPID */
1291 } while (w != child);
1293 You can specify formats for languages other than C by using line
1294 group formats and line formats, as described in the next sections.
1298 * Line Group Formats:: Formats for general if-then-else line groups.
1299 * Line Formats:: Formats for each line in a line group.
1300 * Example If-then-else:: Sample if-then-else format output.
1301 * Detailed If-then-else:: A detailed description of if-then-else format.
1304 File: diff.info, Node: Line Group Formats, Next: Line Formats, Up: If-then-else
1306 2.6.1 Line Group Formats
1307 ------------------------
1309 Line group formats let you specify formats suitable for many
1310 applications that allow if-then-else input, including programming
1311 languages and text formatting languages. A line group format specifies
1312 the output format for a contiguous group of similar lines.
1314 For example, the following command compares the TeX files `old' and
1315 `new', and outputs a merged file in which old regions are surrounded by
1316 `\begin{em}'-`\end{em}' lines, and new regions are surrounded by
1317 `\begin{bf}'-`\end{bf}' lines.
1320 --old-group-format='\begin{em}
1323 --new-group-format='\begin{bf}
1328 The following command is equivalent to the above example, but it is a
1329 little more verbose, because it spells out the default line group
1333 --old-group-format='\begin{em}
1336 --new-group-format='\begin{bf}
1339 --unchanged-group-format='%=' \
1340 --changed-group-format='\begin{em}
1347 Here is a more advanced example, which outputs a diff listing with
1348 headers containing line numbers in a "plain English" style.
1351 --unchanged-group-format='' \
1352 --old-group-format='-------- %dn line%(n=1?:s) deleted at %df:
1354 --new-group-format='-------- %dN line%(N=1?:s) added after %de:
1356 --changed-group-format='-------- %dn line%(n=1?:s) changed at %df:
1361 To specify a line group format, use `diff' with one of the options
1362 listed below. You can specify up to four line group formats, one for
1363 each kind of line group. You should quote FORMAT, because it typically
1364 contains shell metacharacters.
1366 `--old-group-format=FORMAT'
1367 These line groups are hunks containing only lines from the first
1368 file. The default old group format is the same as the changed
1369 group format if it is specified; otherwise it is a format that
1370 outputs the line group as-is.
1372 `--new-group-format=FORMAT'
1373 These line groups are hunks containing only lines from the second
1374 file. The default new group format is same as the changed group
1375 format if it is specified; otherwise it is a format that outputs
1376 the line group as-is.
1378 `--changed-group-format=FORMAT'
1379 These line groups are hunks containing lines from both files. The
1380 default changed group format is the concatenation of the old and
1383 `--unchanged-group-format=FORMAT'
1384 These line groups contain lines common to both files. The default
1385 unchanged group format is a format that outputs the line group
1388 In a line group format, ordinary characters represent themselves;
1389 conversion specifications start with `%' and have one of the following
1393 stands for the lines from the first file, including the trailing
1394 newline. Each line is formatted according to the old line format
1395 (*note Line Formats::).
1398 stands for the lines from the second file, including the trailing
1399 newline. Each line is formatted according to the new line format.
1402 stands for the lines common to both files, including the trailing
1403 newline. Each line is formatted according to the unchanged line
1410 where C is a single character, stands for C. C may not be a
1411 backslash or an apostrophe. For example, `%c':'' stands for a
1412 colon, even inside the then-part of an if-then-else format, which
1413 a colon would normally terminate.
1416 where O is a string of 1, 2, or 3 octal digits, stands for the
1417 character with octal code O. For example, `%c'\0'' stands for a
1421 where F is a `printf' conversion specification and N is one of the
1422 following letters, stands for N's value formatted with F.
1425 The line number of the line just before the group in the old
1429 The line number of the first line in the group in the old
1433 The line number of the last line in the group in the old file.
1436 The line number of the line just after the group in the old
1440 The number of lines in the group in the old file; equals L -
1444 Likewise, for lines in the new file.
1447 The `printf' conversion specification can be `%d', `%o', `%x', or
1448 `%X', specifying decimal, octal, lower case hexadecimal, or upper
1449 case hexadecimal output respectively. After the `%' the following
1450 options can appear in sequence: a series of zero or more flags; an
1451 integer specifying the minimum field width; and a period followed
1452 by an optional integer specifying the minimum number of digits.
1453 The flags are `-' for left-justification, `'' for separating the
1454 digit into groups as specified by the `LC_NUMERIC' locale category,
1455 and `0' for padding with zeros instead of spaces. For example,
1456 `%5dN' prints the number of new lines in the group in a field of
1457 width 5 characters, using the `printf' format `"%5d"'.
1460 If A equals B then T else E. A and B are each either a decimal
1461 constant or a single letter interpreted as above. This format
1462 spec is equivalent to T if A's value equals B's; otherwise it is
1465 For example, `%(N=0?no:%dN) line%(N=1?:s)' is equivalent to `no
1466 lines' if N (the number of lines in the group in the new file) is
1467 0, to `1 line' if N is 1, and to `%dN lines' otherwise.
1470 File: diff.info, Node: Line Formats, Next: Example If-then-else, Prev: Line Group Formats, Up: If-then-else
1475 Line formats control how each line taken from an input file is output
1476 as part of a line group in if-then-else format.
1478 For example, the following command outputs text with a one-character
1479 change indicator to the left of the text. The first character of output
1480 is `-' for deleted lines, `|' for added lines, and a space for
1481 unchanged lines. The formats contain newline characters where newlines
1482 are desired on output.
1485 --old-line-format='-%l
1487 --new-line-format='|%l
1489 --unchanged-line-format=' %l
1493 To specify a line format, use one of the following options. You
1494 should quote FORMAT, since it often contains shell metacharacters.
1496 `--old-line-format=FORMAT'
1497 formats lines just from the first file.
1499 `--new-line-format=FORMAT'
1500 formats lines just from the second file.
1502 `--unchanged-line-format=FORMAT'
1503 formats lines common to both files.
1505 `--line-format=FORMAT'
1506 formats all lines; in effect, it sets all three above options
1509 In a line format, ordinary characters represent themselves;
1510 conversion specifications start with `%' and have one of the following
1514 stands for the contents of the line, not counting its trailing
1515 newline (if any). This format ignores whether the line is
1516 incomplete; *Note Incomplete Lines::.
1519 stands for the contents of the line, including its trailing newline
1520 (if any). If a line is incomplete, this format preserves its
1527 where C is a single character, stands for C. C may not be a
1528 backslash or an apostrophe. For example, `%c':'' stands for a
1532 where O is a string of 1, 2, or 3 octal digits, stands for the
1533 character with octal code O. For example, `%c'\0'' stands for a
1537 where F is a `printf' conversion specification, stands for the
1538 line number formatted with F. For example, `%.5dn' prints the
1539 line number using the `printf' format `"%.5d"'. *Note Line Group
1540 Formats::, for more about printf conversion specifications.
1543 The default line format is `%l' followed by a newline character.
1545 If the input contains tab characters and it is important that they
1546 line up on output, you should ensure that `%l' or `%L' in a line format
1547 is just after a tab stop (e.g. by preceding `%l' or `%L' with a tab
1548 character), or you should use the `-t' or `--expand-tabs' option.
1550 Taken together, the line and line group formats let you specify many
1551 different formats. For example, the following command uses a format
1552 similar to normal `diff' format. You can tailor this command to get
1553 fine control over `diff' output.
1556 --old-line-format='< %l
1558 --new-line-format='> %l
1560 --old-group-format='%df%(f=l?:,%dl)d%dE
1562 --new-group-format='%dea%dF%(F=L?:,%dL)
1564 --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL)
1567 --unchanged-group-format='' \
1571 File: diff.info, Node: Example If-then-else, Next: Detailed If-then-else, Prev: Line Formats, Up: If-then-else
1573 2.6.3 An Example of If-then-else Format
1574 ---------------------------------------
1576 Here is the output of `diff -DTWO lao tzu' (*note Sample diff Input::,
1577 for the complete contents of the two files):
1580 The Way that can be told of is not the eternal Way;
1581 The name that can be named is not the eternal name.
1583 The Nameless is the origin of Heaven and Earth;
1585 The Named is the mother of all things.
1587 The named is the mother of all things.
1590 Therefore let there always be non-being,
1591 so we may see their subtlety,
1592 And let there always be being,
1593 so we may see their outcome.
1594 The two are the same,
1595 But after they are produced,
1596 they have different names.
1598 They both may be called deep and profound.
1599 Deeper and more profound,
1600 The door of all subtleties!
1604 File: diff.info, Node: Detailed If-then-else, Prev: Example If-then-else, Up: If-then-else
1606 2.6.4 Detailed Description of If-then-else Format
1607 -------------------------------------------------
1609 For lines common to both files, `diff' uses the unchanged line group
1610 format. For each hunk of differences in the merged output format, if
1611 the hunk contains only lines from the first file, `diff' uses the old
1612 line group format; if the hunk contains only lines from the second
1613 file, `diff' uses the new group format; otherwise, `diff' uses the
1614 changed group format.
1616 The old, new, and unchanged line formats specify the output format of
1617 lines from the first file, lines from the second file, and lines common
1618 to both files, respectively.
1620 The option `--ifdef=NAME' is equivalent to the following sequence of
1621 options using shell syntax:
1623 --old-group-format='#ifndef NAME
1624 %<#endif /* ! NAME */
1626 --new-group-format='#ifdef NAME
1629 --unchanged-group-format='%=' \
1630 --changed-group-format='#ifndef NAME
1635 You should carefully check the `diff' output for proper nesting.
1636 For example, when using the `-D NAME' or `--ifdef=NAME' option, you
1637 should check that if the differing lines contain any of the C
1638 preprocessor directives `#ifdef', `#ifndef', `#else', `#elif', or
1639 `#endif', they are nested properly and match. If they don't, you must
1640 make corrections manually. It is a good idea to carefully check the
1641 resulting code anyway to make sure that it really does what you want it
1642 to; depending on how the input files were produced, the output might
1643 contain duplicate or otherwise incorrect code.
1645 The `patch' `-D NAME' option behaves like the `diff' `-D NAME'
1646 option, except it operates on a file and a diff to produce a merged
1647 file; *Note patch Options::.
1650 File: diff.info, Node: Incomplete Lines, Next: Comparing Directories, Prev: Output Formats, Up: Top
1655 When an input file ends in a non-newline character, its last line is
1656 called an "incomplete line" because its last character is not a
1657 newline. All other lines are called "full lines" and end in a newline
1658 character. Incomplete lines do not match full lines unless differences
1659 in white space are ignored (*note White Space::).
1661 An incomplete line is normally distinguished on output from a full
1662 line by a following line that starts with `\'. However, the RCS format
1663 (*note RCS::) outputs the incomplete line as-is, without any trailing
1664 newline or following line. The side by side format normally represents
1665 incomplete lines as-is, but in some cases uses a `\' or `/' gutter
1666 marker; *Note Side by Side::. The if-then-else line format preserves a
1667 line's incompleteness with `%L', and discards the newline with `%l';
1668 *Note Line Formats::. Finally, with the `ed' and forward `ed' output
1669 formats (*note Output Formats::) `diff' cannot represent an incomplete
1670 line, so it pretends there was a newline and reports an error.
1672 For example, suppose `F' and `G' are one-byte files that contain
1673 just `f' and `g', respectively. Then `diff F G' outputs
1677 \ No newline at end of file
1680 \ No newline at end of file
1682 (The exact message may differ in non-English locales.) `diff -n F G'
1683 outputs the following without a trailing newline:
1689 `diff -e F G' reports two errors and outputs the following:
1696 File: diff.info, Node: Comparing Directories, Next: Adjusting Output, Prev: Incomplete Lines, Up: Top
1698 4 Comparing Directories
1699 ***********************
1701 You can use `diff' to compare some or all of the files in two directory
1702 trees. When both file name arguments to `diff' are directories, it
1703 compares each file that is contained in both directories, examining
1704 file names in alphabetical order as specified by the `LC_COLLATE'
1705 locale category. Normally `diff' is silent about pairs of files that
1706 contain no differences, but if you use the `-s' or
1707 `--report-identical-files' option, it reports pairs of identical files.
1708 Normally `diff' reports subdirectories common to both directories
1709 without comparing subdirectories' files, but if you use the `-r' or
1710 `--recursive' option, it compares every corresponding pair of files in
1711 the directory trees, as many levels deep as they go.
1713 For file names that are in only one of the directories, `diff'
1714 normally does not show the contents of the file that exists; it reports
1715 only that the file exists in that directory and not in the other. You
1716 can make `diff' act as though the file existed but was empty in the
1717 other directory, so that it outputs the entire contents of the file that
1718 actually exists. (It is output as either an insertion or a deletion,
1719 depending on whether it is in the first or the second directory given.)
1720 To do this, use the `-N' or `--new-file' option.
1722 If the older directory contains one or more large files that are not
1723 in the newer directory, you can make the patch smaller by using the
1724 `--unidirectional-new-file' option instead of `-N'. This option is
1725 like `-N' except that it only inserts the contents of files that appear
1726 in the second directory but not the first (that is, files that were
1727 added). At the top of the patch, write instructions for the user
1728 applying the patch to remove the files that were deleted before
1729 applying the patch. *Note Making Patches::, for more discussion of
1730 making patches for distribution.
1732 To ignore some files while comparing directories, use the `-x
1733 PATTERN' or `--exclude=PATTERN' option. This option ignores any files
1734 or subdirectories whose base names match the shell pattern PATTERN.
1735 Unlike in the shell, a period at the start of the base of a file name
1736 matches a wildcard at the start of a pattern. You should enclose
1737 PATTERN in quotes so that the shell does not expand it. For example,
1738 the option `-x '*.[ao]'' ignores any file whose name ends with `.a' or
1741 This option accumulates if you specify it more than once. For
1742 example, using the options `-x 'RCS' -x '*,v'' ignores any file or
1743 subdirectory whose base name is `RCS' or ends with `,v'.
1745 If you need to give this option many times, you can instead put the
1746 patterns in a file, one pattern per line, and use the `-X FILE' or
1747 `--exclude-from=FILE' option. Trailing white space and empty lines are
1748 ignored in the pattern file.
1750 If you have been comparing two directories and stopped partway
1751 through, later you might want to continue where you left off. You can
1752 do this by using the `-S FILE' or `--starting-file=FILE' option. This
1753 compares only the file FILE and all alphabetically later files in the
1754 topmost directory level.
1756 If two directories differ only in that file names are lower case in
1757 one directory and upper case in the upper, `diff' normally reports many
1758 differences because it compares file names in a case sensitive way.
1759 With the `--ignore-file-name-case' option, `diff' ignores case
1760 differences in file names, so that for example the contents of the file
1761 `Tao' in one directory are compared to the contents of the file `TAO'
1762 in the other. The `--no-ignore-file-name-case' option cancels the
1763 effect of the `--ignore-file-name-case' option, reverting to the default
1766 If an `-x PATTERN' or `--exclude=PATTERN' option, or an `-X FILE' or
1767 `--exclude-from=FILE' option, is specified while the
1768 `--ignore-file-name-case' option is in effect, case is ignored when
1769 excluding file names matching the specified patterns.
1772 File: diff.info, Node: Adjusting Output, Next: diff Performance, Prev: Comparing Directories, Up: Top
1774 5 Making `diff' Output Prettier
1775 *******************************
1777 `diff' provides several ways to adjust the appearance of its output.
1778 These adjustments can be applied to any output format.
1782 * Tabs:: Preserving the alignment of tab stops.
1783 * Pagination:: Page numbering and time-stamping `diff' output.
1786 File: diff.info, Node: Tabs, Next: Pagination, Up: Adjusting Output
1788 5.1 Preserving Tab Stop Alignment
1789 =================================
1791 The lines of text in some of the `diff' output formats are preceded by
1792 one or two characters that indicate whether the text is inserted,
1793 deleted, or changed. The addition of those characters can cause tabs
1794 to move to the next tab stop, throwing off the alignment of columns in
1795 the line. GNU `diff' provides two ways to make tab-aligned columns
1798 The first way is to have `diff' convert all tabs into the correct
1799 number of spaces before outputting them; select this method with the
1800 `-t' or `--expand-tabs' option. To use this form of output with
1801 `patch', you must give `patch' the `-l' or `--ignore-white-space'
1802 option (*note Changed White Space::, for more information). `diff'
1803 normally assumes that tab stops are set every 8 print columns, but this
1804 can be altered by the `--tabsize=COLUMNS' option.
1806 The other method for making tabs line up correctly is to add a tab
1807 character instead of a space after the indicator character at the
1808 beginning of the line. This ensures that all following tab characters
1809 are in the same position relative to tab stops that they were in the
1810 original files, so that the output is aligned correctly. Its
1811 disadvantage is that it can make long lines too long to fit on one line
1812 of the screen or the paper. It also does not work with the unified
1813 output format, which does not have a space character after the change
1814 type indicator character. Select this method with the `-T' or
1815 `--initial-tab' option.
1818 File: diff.info, Node: Pagination, Prev: Tabs, Up: Adjusting Output
1820 5.2 Paginating `diff' Output
1821 ============================
1823 It can be convenient to have long output page-numbered and time-stamped.
1824 The `-l' or `--paginate' option does this by sending the `diff' output
1825 through the `pr' program. Here is what the page header might look like
1826 for `diff -lc lao tzu':
1828 2002-02-22 14:20 diff -lc lao tzu Page 1
1831 File: diff.info, Node: diff Performance, Next: Comparing Three Files, Prev: Adjusting Output, Up: Top
1833 6 `diff' Performance Tradeoffs
1834 ******************************
1836 GNU `diff' runs quite efficiently; however, in some circumstances you
1837 can cause it to run faster or produce a more compact set of changes.
1839 One way to improve `diff' performance is to use hard or symbolic
1840 links to files instead of copies. This improves performance because
1841 `diff' normally does not need to read two hard or symbolic links to the
1842 same file, since their contents must be identical. For example,
1843 suppose you copy a large directory hierarchy, make a few changes to the
1844 copy, and then often use `diff -r' to compare the original to the copy.
1845 If the original files are read-only, you can greatly improve
1846 performance by creating the copy using hard or symbolic links (e.g.,
1847 with GNU `cp -lR' or `cp -sR'). Before editing a file in the copy for
1848 the first time, you should break the link and replace it with a regular
1851 You can also affect the performance of GNU `diff' by giving it
1852 options that change the way it compares files. Performance has more
1853 than one dimension. These options improve one aspect of performance at
1854 the cost of another, or they improve performance in some cases while
1855 hurting it in others.
1857 The way that GNU `diff' determines which lines have changed always
1858 comes up with a near-minimal set of differences. Usually it is good
1859 enough for practical purposes. If the `diff' output is large, you
1860 might want `diff' to use a modified algorithm that sometimes produces a
1861 smaller set of differences. The `-d' or `--minimal' option does this;
1862 however, it can also cause `diff' to run more slowly than usual, so it
1863 is not the default behavior.
1865 When the files you are comparing are large and have small groups of
1866 changes scattered throughout them, you can use the
1867 `--speed-large-files' option to make a different modification to the
1868 algorithm that `diff' uses. If the input files have a constant small
1869 density of changes, this option speeds up the comparisons without
1870 changing the output. If not, `diff' might produce a larger set of
1871 differences; however, the output will still be correct.
1873 Normally `diff' discards the prefix and suffix that is common to
1874 both files before it attempts to find a minimal set of differences.
1875 This makes `diff' run faster, but occasionally it may produce
1876 non-minimal output. The `--horizon-lines=LINES' option prevents `diff'
1877 from discarding the last LINES lines of the prefix and the first LINES
1878 lines of the suffix. This gives `diff' further opportunities to find a
1881 Suppose a run of changed lines includes a sequence of lines at one
1882 end and there is an identical sequence of lines just outside the other
1883 end. The `diff' command is free to choose which identical sequence is
1884 included in the hunk. In this case, `diff' normally shifts the hunk's
1885 boundaries when this merges adjacent hunks, or shifts a hunk's lines
1886 towards the end of the file. Merging hunks can make the output look
1887 nicer in some cases.
1890 File: diff.info, Node: Comparing Three Files, Next: diff3 Merging, Prev: diff Performance, Up: Top
1892 7 Comparing Three Files
1893 ***********************
1895 Use the program `diff3' to compare three files and show any differences
1896 among them. (`diff3' can also merge files; see *Note diff3 Merging::).
1898 The "normal" `diff3' output format shows each hunk of differences
1899 without surrounding context. Hunks are labeled depending on whether
1900 they are two-way or three-way, and lines are annotated by their
1901 location in the input files.
1903 *Note Invoking diff3::, for more information on how to run `diff3'.
1907 * Sample diff3 Input:: Sample `diff3' input for examples.
1908 * Example diff3 Normal:: Sample output in the normal format.
1909 * diff3 Hunks:: The format of normal output format.
1910 * Detailed diff3 Normal:: A detailed description of normal output format.
1913 File: diff.info, Node: Sample diff3 Input, Next: Example diff3 Normal, Up: Comparing Three Files
1915 7.1 A Third Sample Input File
1916 =============================
1918 Here is a third sample file that will be used in examples to illustrate
1919 the output of `diff3' and how various options can change it. The first
1920 two files are the same that we used for `diff' (*note Sample diff
1921 Input::). This is the third sample file, called `tao':
1923 The Way that can be told of is not the eternal Way;
1924 The name that can be named is not the eternal name.
1925 The Nameless is the origin of Heaven and Earth;
1926 The named is the mother of all things.
1928 Therefore let there always be non-being,
1929 so we may see their subtlety,
1930 And let there always be being,
1931 so we may see their result.
1932 The two are the same,
1933 But after they are produced,
1934 they have different names.
1936 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
1939 File: diff.info, Node: Example diff3 Normal, Next: diff3 Hunks, Prev: Sample diff3 Input, Up: Comparing Three Files
1941 7.2 An Example of `diff3' Normal Format
1942 =======================================
1944 Here is the output of the command `diff3 lao tzu tao' (*note Sample
1945 diff3 Input::, for the complete contents of the files). Notice that it
1946 shows only the lines that are different among the three files.
1951 The Way that can be told of is not the eternal Way;
1952 The name that can be named is not the eternal name.
1956 The Named is the mother of all things.
1959 The named is the mother of all things.
1964 so we may see their outcome.
1966 so we may see their result.
1970 They both may be called deep and profound.
1971 Deeper and more profound,
1972 The door of all subtleties!
1975 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
1978 File: diff.info, Node: Detailed diff3 Normal, Prev: diff3 Hunks, Up: Comparing Three Files
1980 7.3 Detailed Description of `diff3' Normal Format
1981 =================================================
1983 Each hunk begins with a line marked `===='. Three-way hunks have plain
1984 `====' lines, and two-way hunks have `1', `2', or `3' appended to
1985 specify which of the three input files differ in that hunk. The hunks
1986 contain copies of two or three sets of input lines each preceded by one
1987 or two commands identifying where the lines came from.
1989 Normally, two spaces precede each copy of an input line to
1990 distinguish it from the commands. But with the `-T' or `--initial-tab'
1991 option, `diff3' uses a tab instead of two spaces; this lines up tabs
1992 correctly. *Note Tabs::, for more information.
1994 Commands take the following forms:
1997 This hunk appears after line L of file FILE, and contains no lines
1998 in that file. To edit this file to yield the other files, one
1999 must append hunk lines taken from the other files. For example,
2000 `1:11a' means that the hunk follows line 11 in the first file and
2001 contains no lines from that file.
2004 This hunk contains the lines in the range R of file FILE. The
2005 range R is a comma-separated pair of line numbers, or just one
2006 number if the range is a singleton. To edit this file to yield the
2007 other files, one must change the specified lines to be the lines
2008 taken from the other files. For example, `2:11,13c' means that
2009 the hunk contains lines 11 through 13 from the second file.
2011 If the last line in a set of input lines is incomplete (*note
2012 Incomplete Lines::), it is distinguished on output from a full line by
2013 a following line that starts with `\'.
2016 File: diff.info, Node: diff3 Hunks, Next: Detailed diff3 Normal, Prev: Example diff3 Normal, Up: Comparing Three Files
2021 Groups of lines that differ in two or three of the input files are
2022 called "diff3 hunks", by analogy with `diff' hunks (*note Hunks::). If
2023 all three input files differ in a `diff3' hunk, the hunk is called a
2024 "three-way hunk"; if just two input files differ, it is a "two-way
2027 As with `diff', several solutions are possible. When comparing the
2028 files `A', `B', and `C', `diff3' normally finds `diff3' hunks by
2029 merging the two-way hunks output by the two commands `diff A B' and
2030 `diff A C'. This does not necessarily minimize the size of the output,
2031 but exceptions should be rare.
2033 For example, suppose `F' contains the three lines `a', `b', `f', `G'
2034 contains the lines `g', `b', `g', and `H' contains the lines `a', `b',
2035 `h'. `diff3 F G H' might output the following:
2051 because it found a two-way hunk containing `a' in the first and third
2052 files and `g' in the second file, then the single line `b' common to
2053 all three files, then a three-way hunk containing the last line of each
2057 File: diff.info, Node: diff3 Merging, Next: Interactive Merging, Prev: Comparing Three Files, Up: Top
2059 8 Merging From a Common Ancestor
2060 ********************************
2062 When two people have made changes to copies of the same file, `diff3'
2063 can produce a merged output that contains both sets of changes together
2064 with warnings about conflicts.
2066 One might imagine programs with names like `diff4' and `diff5' to
2067 compare more than three files simultaneously, but in practice the need
2068 rarely arises. You can use `diff3' to merge three or more sets of
2069 changes to a file by merging two change sets at a time.
2071 `diff3' can incorporate changes from two modified versions into a
2072 common preceding version. This lets you merge the sets of changes
2073 represented by the two newer files. Specify the common ancestor version
2074 as the second argument and the two newer versions as the first and third
2075 arguments, like this:
2077 diff3 MINE OLDER YOURS
2079 You can remember the order of the arguments by noting that they are in
2082 You can think of this as subtracting OLDER from YOURS and adding the
2083 result to MINE, or as merging into MINE the changes that would turn
2084 OLDER into YOURS. This merging is well-defined as long as MINE and
2085 OLDER match in the neighborhood of each such change. This fails to be
2086 true when all three input files differ or when only OLDER differs; we
2087 call this a "conflict". When all three input files differ, we call the
2088 conflict an "overlap".
2090 `diff3' gives you several ways to handle overlaps and conflicts.
2091 You can omit overlaps or conflicts, or select only overlaps, or mark
2092 conflicts with special `<<<<<<<' and `>>>>>>>' lines.
2094 `diff3' can output the merge results as an `ed' script that that can
2095 be applied to the first file to yield the merged output. However, it
2096 is usually better to have `diff3' generate the merged output directly;
2097 this bypasses some problems with `ed'.
2101 * Which Changes:: Selecting changes to incorporate.
2102 * Marking Conflicts:: Marking conflicts.
2103 * Bypassing ed:: Generating merged output directly.
2104 * Merging Incomplete Lines:: How `diff3' merges incomplete lines.
2105 * Saving the Changed File:: Emulating System V behavior.
2108 File: diff.info, Node: Which Changes, Next: Marking Conflicts, Up: diff3 Merging
2110 8.1 Selecting Which Changes to Incorporate
2111 ==========================================
2113 You can select all unmerged changes from OLDER to YOURS for merging
2114 into MINE with the `-e' or `--ed' option. You can select only the
2115 nonoverlapping unmerged changes with `-3' or `--easy-only', and you can
2116 select only the overlapping changes with `-x' or `--overlap-only'.
2118 The `-e', `-3' and `-x' options select only "unmerged changes", i.e.
2119 changes where MINE and YOURS differ; they ignore changes from OLDER to
2120 YOURS where MINE and YOURS are identical, because they assume that such
2121 changes have already been merged. If this assumption is not a safe
2122 one, you can use the `-A' or `--show-all' option (*note Marking
2125 Here is the output of the command `diff3' with each of these three
2126 options (*note Sample diff3 Input::, for the complete contents of the
2127 files). Notice that `-e' outputs the union of the disjoint sets of
2128 changes output by `-3' and `-x'.
2130 Output of `diff3 -e lao tzu tao':
2133 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2136 so we may see their result.
2139 Output of `diff3 -3 lao tzu tao':
2141 so we may see their result.
2144 Output of `diff3 -x lao tzu tao':
2147 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2151 File: diff.info, Node: Marking Conflicts, Next: Bypassing ed, Prev: Which Changes, Up: diff3 Merging
2153 8.2 Marking Conflicts
2154 =====================
2156 `diff3' can mark conflicts in the merged output by bracketing them with
2157 special marker lines. A conflict that comes from two files A and B is
2166 A conflict that comes from three files A, B and C is marked as
2177 The `-A' or `--show-all' option acts like the `-e' option, except
2178 that it brackets conflicts, and it outputs all changes from OLDER to
2179 YOURS, not just the unmerged changes. Thus, given the sample input
2180 files (*note Sample diff3 Input::), `diff3 -A lao tzu tao' puts
2181 brackets around the conflict where only `tzu' differs:
2185 The Way that can be told of is not the eternal Way;
2186 The name that can be named is not the eternal name.
2189 And it outputs the three-way conflict as follows:
2193 They both may be called deep and profound.
2194 Deeper and more profound,
2195 The door of all subtleties!
2198 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2201 The `-E' or `--show-overlap' option outputs less information than
2202 the `-A' or `--show-all' option, because it outputs only unmerged
2203 changes, and it never outputs the contents of the second file. Thus
2204 the `-E' option acts like the `-e' option, except that it brackets the
2205 first and third files from three-way overlapping changes. Similarly,
2206 `-X' acts like `-x', except it brackets all its (necessarily
2207 overlapping) changes. For example, for the three-way overlapping
2208 change above, the `-E' and `-X' options output the following:
2213 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2216 If you are comparing files that have meaningless or uninformative
2217 names, you can use the `--label=LABEL' option to show alternate names
2218 in the `<<<<<<<', `|||||||' and `>>>>>>>' brackets. This option can be
2219 given up to three times, once for each input file. Thus `diff3 -A
2220 --label X --label Y --label Z A B C' acts like `diff3 -A A B C', except
2221 that the output looks like it came from files named `X', `Y' and `Z'
2222 rather than from files named `A', `B' and `C'.
2225 File: diff.info, Node: Bypassing ed, Next: Merging Incomplete Lines, Prev: Marking Conflicts, Up: diff3 Merging
2227 8.3 Generating the Merged Output Directly
2228 =========================================
2230 With the `-m' or `--merge' option, `diff3' outputs the merged file
2231 directly. This is more efficient than using `ed' to generate it, and
2232 works even with non-text files that `ed' would reject. If you specify
2233 `-m' without an `ed' script option, `-A' is assumed.
2235 For example, the command `diff3 -m lao tzu tao' (*note Sample diff3
2236 Input:: for a copy of the input files) would output the following:
2240 The Way that can be told of is not the eternal Way;
2241 The name that can be named is not the eternal name.
2243 The Nameless is the origin of Heaven and Earth;
2244 The Named is the mother of all things.
2245 Therefore let there always be non-being,
2246 so we may see their subtlety,
2247 And let there always be being,
2248 so we may see their result.
2249 The two are the same,
2250 But after they are produced,
2251 they have different names.
2254 They both may be called deep and profound.
2255 Deeper and more profound,
2256 The door of all subtleties!
2259 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2263 File: diff.info, Node: Merging Incomplete Lines, Next: Saving the Changed File, Prev: Bypassing ed, Up: diff3 Merging
2265 8.4 How `diff3' Merges Incomplete Lines
2266 =======================================
2268 With `-m', incomplete lines (*note Incomplete Lines::) are simply
2269 copied to the output as they are found; if the merged output ends in an
2270 conflict and one of the input files ends in an incomplete line,
2271 succeeding `|||||||', `=======' or `>>>>>>>' brackets appear somewhere
2272 other than the start of a line because they are appended to the
2275 Without `-m', if an `ed' script option is specified and an
2276 incomplete line is found, `diff3' generates a warning and acts as if a
2277 newline had been present.
2280 File: diff.info, Node: Saving the Changed File, Prev: Merging Incomplete Lines, Up: diff3 Merging
2282 8.5 Saving the Changed File
2283 ===========================
2285 Traditional Unix `diff3' generates an `ed' script without the trailing
2286 `w' and `q' commands that save the changes. System V `diff3' generates
2287 these extra commands. GNU `diff3' normally behaves like traditional
2288 Unix `diff3', but with the `-i' option it behaves like System V `diff3'
2289 and appends the `w' and `q' commands.
2291 The `-i' option requires one of the `ed' script options `-AeExX3',
2292 and is incompatible with the merged output option `-m'.
2295 File: diff.info, Node: Interactive Merging, Next: Merging with patch, Prev: diff3 Merging, Up: Top
2297 9 Interactive Merging with `sdiff'
2298 **********************************
2300 With `sdiff', you can merge two files interactively based on a
2301 side-by-side `-y' format comparison (*note Side by Side::). Use `-o
2302 FILE' or `--output=FILE' to specify where to put the merged text.
2303 *Note Invoking sdiff::, for more details on the options to `sdiff'.
2305 Another way to merge files interactively is to use the Emacs Lisp
2306 package `emerge'. *Note emerge: (emacs)emerge, for more information.
2310 * sdiff Option Summary:: Summary of `sdiff' options.
2311 * Merge Commands:: Merging two files interactively.
2314 File: diff.info, Node: sdiff Option Summary, Next: Merge Commands, Up: Interactive Merging
2316 9.1 Specifying `diff' Options to `sdiff'
2317 ========================================
2319 The following `sdiff' options have the same meaning as for `diff'.
2320 *Note diff Options::, for the use of these options.
2326 --ignore-blank-lines --ignore-case
2327 --ignore-matching-lines=REGEXP --ignore-space-change
2328 --ignore-tab-expansion
2329 --left-column --minimal --speed-large-files
2330 --strip-trailing-cr --suppress-common-lines
2331 --tabsize=COLUMNS --text --version --width=COLUMNS
2333 For historical reasons, `sdiff' has alternate names for some
2334 options. The `-l' option is equivalent to the `--left-column' option,
2335 and similarly `-s' is equivalent to `--suppress-common-lines'. The
2336 meaning of the `sdiff' `-w' and `-W' options is interchanged from that
2337 of `diff': with `sdiff', `-w COLUMNS' is equivalent to
2338 `--width=COLUMNS', and `-W' is equivalent to `--ignore-all-space'.
2339 `sdiff' without the `-o' option is equivalent to `diff' with the `-y'
2340 or `--side-by-side' option (*note Side by Side::).
2343 File: diff.info, Node: Merge Commands, Prev: sdiff Option Summary, Up: Interactive Merging
2348 Groups of common lines, with a blank gutter, are copied from the first
2349 file to the output. After each group of differing lines, `sdiff'
2350 prompts with `%' and pauses, waiting for one of the following commands.
2351 Follow each command with <RET>.
2354 Discard both versions. Invoke a text editor on an empty temporary
2355 file, then copy the resulting file to the output.
2358 Concatenate the two versions, edit the result in a temporary file,
2359 then copy the edited result to the output.
2362 Like `eb', except precede each version with a header that shows
2363 what file and lines the version came from.
2366 Edit a copy of the left version, then copy the result to the
2370 Edit a copy of the right version, then copy the result to the
2374 Copy the left version to the output.
2380 Copy the right version to the output.
2383 Silently copy common lines.
2386 Verbosely copy common lines. This is the default.
2388 The text editor invoked is specified by the `EDITOR' environment
2389 variable if it is set. The default is system-dependent.
2392 File: diff.info, Node: Merging with patch, Next: Making Patches, Prev: Interactive Merging, Up: Top
2394 10 Merging with `patch'
2395 ***********************
2397 `patch' takes comparison output produced by `diff' and applies the
2398 differences to a copy of the original file, producing a patched
2399 version. With `patch', you can distribute just the changes to a set of
2400 files instead of distributing the entire file set; your correspondents
2401 can apply `patch' to update their copy of the files with your changes.
2402 `patch' automatically determines the diff format, skips any leading or
2403 trailing headers, and uses the headers to determine which file to
2404 patch. This lets your correspondents feed a mail message containing a
2405 difference listing directly to `patch'.
2407 `patch' detects and warns about common problems like forward
2408 patches. It saves any patches that it could not apply. It can also
2409 maintain a `patchlevel.h' file to ensure that your correspondents apply
2410 diffs in the proper order.
2412 `patch' accepts a series of diffs in its standard input, usually
2413 separated by headers that specify which file to patch. It applies
2414 `diff' hunks (*note Hunks::) one by one. If a hunk does not exactly
2415 match the original file, `patch' uses heuristics to try to patch the
2416 file as well as it can. If no approximate match can be found, `patch'
2417 rejects the hunk and skips to the next hunk. `patch' normally replaces
2418 each file F with its new version, putting reject hunks (if any) into
2421 *Note Invoking patch::, for detailed information on the options to
2426 * patch Input:: Selecting the type of `patch' input.
2427 * Revision Control:: Getting files from RCS, SCCS, etc.
2428 * Imperfect:: Dealing with imperfect patches.
2429 * Creating and Removing:: Creating and removing files with a patch.
2430 * Patching Time Stamps:: Updating time stamps on patched files.
2431 * Multiple Patches:: Handling multiple patches in a file.
2432 * patch Directories:: Changing directory and stripping directories.
2433 * Backups:: Whether backup files are made.
2434 * Backup Names:: Backup file names.
2435 * Reject Names:: Reject file names.
2436 * patch Messages:: Messages and questions `patch' can produce.
2437 * patch and POSIX:: Conformance to the POSIX standard.
2438 * patch and Tradition:: GNU versus traditional `patch'.
2441 File: diff.info, Node: patch Input, Next: Revision Control, Up: Merging with patch
2443 10.1 Selecting the `patch' Input Format
2444 =======================================
2446 `patch' normally determines which `diff' format the patch file uses by
2447 examining its contents. For patch files that contain particularly
2448 confusing leading text, you might need to use one of the following
2449 options to force `patch' to interpret the patch file as a certain
2450 format of diff. The output formats listed here are the only ones that
2451 `patch' can understand.
2470 File: diff.info, Node: Revision Control, Next: Imperfect, Prev: patch Input, Up: Merging with patch
2472 10.2 Revision Control
2473 =====================
2475 If a nonexistent input file is under a revision control system
2476 supported by `patch', `patch' normally asks the user whether to get (or
2477 check out) the file from the revision control system. Patch currently
2478 supports RCS, ClearCase and SCCS. Under RCS and SCCS, `patch' also
2479 asks when the input file is read-only and matches the default version
2480 in the revision control system.
2482 The `-g NUM' or `--get=NUM' option affects access to files under
2483 supported revision control systems. If NUM is positive, `patch' gets
2484 the file without asking the user; if zero, `patch' neither asks the
2485 user nor gets the file; and if negative, `patch' asks the user before
2486 getting the file. The default value of NUM is given by the value of the
2487 `PATCH_GET' environment variable if it is set; if not, the default
2488 value is zero if `patch' is conforming to POSIX, negative otherwise.
2489 *Note patch and POSIX::.
2491 The choice of revision control system is unaffected by the
2492 `VERSION_CONTROL' environment variable (*note Backup Names::).
2495 File: diff.info, Node: Imperfect, Next: Creating and Removing, Prev: Revision Control, Up: Merging with patch
2497 10.3 Applying Imperfect Patches
2498 ===============================
2500 `patch' tries to skip any leading text in the patch file, apply the
2501 diff, and then skip any trailing text. Thus you can feed a mail
2502 message directly to `patch', and it should work. If the entire diff is
2503 indented by a constant amount of white space, `patch' automatically
2504 ignores the indentation. If a context diff contains trailing carriage
2505 return on each line, `patch' automatically ignores the carriage return.
2506 If a context diff has been encapsulated by prepending `- ' to lines
2507 beginning with `-' as per Internet RFC 934
2508 (ftp://ftp.isi.edu/in-notes/rfc934.txt), `patch' automatically
2509 unencapsulates the input.
2511 However, certain other types of imperfect input require user
2512 intervention or testing.
2516 * Changed White Space:: When tabs and spaces don't match exactly.
2517 * Reversed Patches:: Applying reversed patches correctly.
2518 * Inexact:: Helping `patch' find close matches.
2519 * Dry Runs:: Predicting what `patch' will do.
2522 File: diff.info, Node: Changed White Space, Next: Reversed Patches, Up: Imperfect
2524 10.3.1 Applying Patches with Changed White Space
2525 ------------------------------------------------
2527 Sometimes mailers, editors, or other programs change spaces into tabs,
2528 or vice versa. If this happens to a patch file or an input file, the
2529 files might look the same, but `patch' will not be able to match them
2530 properly. If this problem occurs, use the `-l' or
2531 `--ignore-white-space' option, which makes `patch' compare blank
2532 characters (i.e. spaces and tabs) loosely so that any nonempty sequence
2533 of blanks in the patch file matches any nonempty sequence of blanks in
2534 the input files. Non-blank characters must still match exactly. Each
2535 line of the context must still match a line in the input file.
2538 File: diff.info, Node: Reversed Patches, Next: Inexact, Prev: Changed White Space, Up: Imperfect
2540 10.3.2 Applying Reversed Patches
2541 --------------------------------
2543 Sometimes people run `diff' with the new file first instead of second.
2544 This creates a diff that is "reversed". To apply such patches, give
2545 `patch' the `-R' or `--reverse' option. `patch' then attempts to swap
2546 each hunk around before applying it. Rejects come out in the swapped
2549 Often `patch' can guess that the patch is reversed. If the first
2550 hunk of a patch fails, `patch' reverses the hunk to see if it can apply
2551 it that way. If it can, `patch' asks you if you want to have the `-R'
2552 option set; if it can't, `patch' continues to apply the patch normally.
2553 This method cannot detect a reversed patch if it is a normal diff and
2554 the first command is an append (which should have been a delete) since
2555 appends always succeed, because a null context matches anywhere. But
2556 most patches add or change lines rather than delete them, so most
2557 reversed normal diffs begin with a delete, which fails, and `patch'
2560 If you apply a patch that you have already applied, `patch' thinks
2561 it is a reversed patch and offers to un-apply the patch. This could be
2562 construed as a feature. If you did this inadvertently and you don't
2563 want to un-apply the patch, just answer `n' to this offer and to the
2564 subsequent "apply anyway" question--or type `C-c' to kill the `patch'
2568 File: diff.info, Node: Inexact, Next: Dry Runs, Prev: Reversed Patches, Up: Imperfect
2570 10.3.3 Helping `patch' Find Inexact Matches
2571 -------------------------------------------
2573 For context diffs, and to a lesser extent normal diffs, `patch' can
2574 detect when the line numbers mentioned in the patch are incorrect, and
2575 it attempts to find the correct place to apply each hunk of the patch.
2576 As a first guess, it takes the line number mentioned in the hunk, plus
2577 or minus any offset used in applying the previous hunk. If that is not
2578 the correct place, `patch' scans both forward and backward for a set of
2579 lines matching the context given in the hunk.
2581 First `patch' looks for a place where all lines of the context
2582 match. If it cannot find such a place, and it is reading a context or
2583 unified diff, and the maximum fuzz factor is set to 1 or more, then
2584 `patch' makes another scan, ignoring the first and last line of
2585 context. If that fails, and the maximum fuzz factor is set to 2 or
2586 more, it makes another scan, ignoring the first two and last two lines
2587 of context are ignored. It continues similarly if the maximum fuzz
2590 The `-F LINES' or `--fuzz=LINES' option sets the maximum fuzz factor
2591 to LINES. This option only applies to context and unified diffs; it
2592 ignores up to LINES lines while looking for the place to install a
2593 hunk. Note that a larger fuzz factor increases the odds of making a
2594 faulty patch. The default fuzz factor is 2; there is no point to
2595 setting it to more than the number of lines of context in the diff,
2598 If `patch' cannot find a place to install a hunk of the patch, it
2599 writes the hunk out to a reject file (*note Reject Names::, for
2600 information on how reject files are named). It writes out rejected
2601 hunks in context format no matter what form the input patch is in. If
2602 the input is a normal or `ed' diff, many of the contexts are simply
2603 null. The line numbers on the hunks in the reject file may be
2604 different from those in the patch file: they show the approximate
2605 location where `patch' thinks the failed hunks belong in the new file
2606 rather than in the old one.
2608 If the `--verbose' option is given, then as it completes each hunk
2609 `patch' tells you whether the hunk succeeded or failed, and if it
2610 failed, on which line (in the new file) `patch' thinks the hunk should
2611 go. If this is different from the line number specified in the diff,
2612 it tells you the offset. A single large offset _may_ indicate that
2613 `patch' installed a hunk in the wrong place. `patch' also tells you if
2614 it used a fuzz factor to make the match, in which case you should also
2615 be slightly suspicious.
2617 `patch' cannot tell if the line numbers are off in an `ed' script,
2618 and can only detect wrong line numbers in a normal diff when it finds a
2619 change or delete command. It may have the same problem with a context
2620 diff using a fuzz factor equal to or greater than the number of lines
2621 of context shown in the diff (typically 3). In these cases, you should
2622 probably look at a context diff between your original and patched input
2623 files to see if the changes make sense. Compiling without errors is a
2624 pretty good indication that the patch worked, but not a guarantee.
2626 A patch against an empty file applies to a nonexistent file, and vice
2627 versa. *Note Creating and Removing::.
2629 `patch' usually produces the correct results, even when it must make
2630 many guesses. However, the results are guaranteed only when the patch
2631 is applied to an exact copy of the file that the patch was generated
2635 File: diff.info, Node: Dry Runs, Prev: Inexact, Up: Imperfect
2637 10.3.4 Predicting what `patch' will do
2638 --------------------------------------
2640 It may not be obvious in advance what `patch' will do with a
2641 complicated or poorly formatted patch. If you are concerned that the
2642 input might cause `patch' to modify the wrong files, you can use the
2643 `--dry-run' option, which causes `patch' to print the results of
2644 applying patches without actually changing any files. You can then
2645 inspect the diagnostics generated by the dry run to see whether `patch'
2646 will modify the files that you expect. If the patch does not do what
2647 you want, you can modify the patch (or the other options to `patch')
2648 and try another dry run. Once you are satisfied with the proposed
2649 patch you can apply it by invoking `patch' as before, but this time
2650 without the `--dry-run' option.
2653 File: diff.info, Node: Creating and Removing, Next: Patching Time Stamps, Prev: Imperfect, Up: Merging with patch
2655 10.4 Creating and Removing Files
2656 ================================
2658 Sometimes when comparing two directories, a file may exist in one
2659 directory but not the other. If you give `diff' the `-N' or
2660 `--new-file' option, or if you supply an old or new file that is named
2661 `/dev/null' or is empty and is dated the Epoch (1970-01-01 00:00:00
2662 UTC), `diff' outputs a patch that adds or deletes the contents of this
2663 file. When given such a patch, `patch' normally creates a new file or
2664 removes the old file. However, when conforming to POSIX (*note patch
2665 and POSIX::), `patch' does not remove the old file, but leaves it empty.
2666 The `-E' or `--remove-empty-files' option causes `patch' to remove
2667 output files that are empty after applying a patch, even if the patch
2668 does not appear to be one that removed the file.
2670 If the patch appears to create a file that already exists, `patch'
2671 asks for confirmation before applying the patch.
2674 File: diff.info, Node: Patching Time Stamps, Next: Multiple Patches, Prev: Creating and Removing, Up: Merging with patch
2676 10.5 Updating Time Stamps on Patched Files
2677 ==========================================
2679 When `patch' updates a file, it normally sets the file's last-modified
2680 time stamp to the current time of day. If you are using `patch' to
2681 track a software distribution, this can cause `make' to incorrectly
2682 conclude that a patched file is out of date. For example, if
2683 `syntax.c' depends on `syntax.y', and `patch' updates `syntax.c' and
2684 then `syntax.y', then `syntax.c' will normally appear to be out of date
2685 with respect to `syntax.y' even though its contents are actually up to
2688 The `-Z' or `--set-utc' option causes `patch' to set a patched
2689 file's modification and access times to the time stamps given in
2690 context diff headers. If the context diff headers do not specify a
2691 time zone, they are assumed to use Coordinated Universal Time (UTC,
2692 often known as GMT).
2694 The `-T' or `--set-time' option acts like `-Z' or `--set-utc',
2695 except that it assumes that the context diff headers' time stamps use
2696 local time instead of UTC. This option is not recommended, because
2697 patches using local time cannot easily be used by people in other time
2698 zones, and because local time stamps are ambiguous when local clocks
2699 move backwards during daylight-saving time adjustments. If the context
2700 diff headers specify a time zone, this option is equivalent to `-Z' or
2703 `patch' normally refrains from setting a file's time stamps if the
2704 file's original last-modified time stamp does not match the time given
2705 in the diff header, of if the file's contents do not exactly match the
2706 patch. However, if the `-f' or `--force' option is given, the file's
2707 time stamps are set regardless.
2709 Due to the limitations of the current `diff' format, `patch' cannot
2710 update the times of files whose contents have not changed. Also, if
2711 you set file time stamps to values other than the current time of day,
2712 you should also remove (e.g., with `make clean') all files that depend
2713 on the patched files, so that later invocations of `make' do not get
2714 confused by the patched files' times.
2717 File: diff.info, Node: Multiple Patches, Next: patch Directories, Prev: Patching Time Stamps, Up: Merging with patch
2719 10.6 Multiple Patches in a File
2720 ===============================
2722 If the patch file contains more than one patch, and if you do not
2723 specify an input file on the command line, `patch' tries to apply each
2724 patch as if they came from separate patch files. This means that it
2725 determines the name of the file to patch for each patch, and that it
2726 examines the leading text before each patch for file names and
2727 prerequisite revision level (*note Making Patches::, for more on that
2730 `patch' uses the following rules to intuit a file name from the
2731 leading text before a patch. First, `patch' takes an ordered list of
2732 candidate file names as follows:
2734 * If the header is that of a context diff, `patch' takes the old and
2735 new file names in the header. A name is ignored if it does not
2736 have enough slashes to satisfy the `-pNUM' or `--strip=NUM'
2737 option. The name `/dev/null' is also ignored.
2739 * If there is an `Index:' line in the leading garbage and if either
2740 the old and new names are both absent or if `patch' is conforming
2741 to POSIX, `patch' takes the name in the `Index:' line.
2743 * For the purpose of the following rules, the candidate file names
2744 are considered to be in the order (old, new, index), regardless of
2745 the order that they appear in the header.
2747 Then `patch' selects a file name from the candidate list as follows:
2749 * If some of the named files exist, `patch' selects the first name
2750 if conforming to POSIX, and the best name otherwise.
2752 * If `patch' is not ignoring RCS, ClearCase, and SCCS (*note
2753 Revision Control::), and no named files exist but an RCS,
2754 ClearCase, or SCCS master is found, `patch' selects the first
2755 named file with an RCS, ClearCase, or SCCS master.
2757 * If no named files exist, no RCS, ClearCase, or SCCS master was
2758 found, some names are given, `patch' is not conforming to POSIX,
2759 and the patch appears to create a file, `patch' selects the best
2760 name requiring the creation of the fewest directories.
2762 * If no file name results from the above heuristics, you are asked
2763 for the name of the file to patch, and `patch' selects that name.
2765 To determine the "best" of a nonempty list of file names, `patch'
2766 first takes all the names with the fewest path name components; of
2767 those, it then takes all the names with the shortest basename; of
2768 those, it then takes all the shortest names; finally, it takes the
2769 first remaining name.
2771 *Note patch and POSIX::, to see whether `patch' is conforming to
2775 File: diff.info, Node: patch Directories, Next: Backups, Prev: Multiple Patches, Up: Merging with patch
2777 10.7 Applying Patches in Other Directories
2778 ==========================================
2780 The `-d DIRECTORY' or `--directory=DIRECTORY' option to `patch' makes
2781 directory DIRECTORY the current directory for interpreting both file
2782 names in the patch file, and file names given as arguments to other
2783 options (such as `-B' and `-o'). For example, while in a mail reading
2784 program, you can patch a file in the `/usr/src/emacs' directory
2785 directly from a message containing the patch like this:
2787 | patch -d /usr/src/emacs
2789 Sometimes the file names given in a patch contain leading
2790 directories, but you keep your files in a directory different from the
2791 one given in the patch. In those cases, you can use the `-pNUMBER' or
2792 `--strip=NUMBER' option to set the file name strip count to NUMBER.
2793 The strip count tells `patch' how many slashes, along with the directory
2794 names between them, to strip from the front of file names. A sequence
2795 of one or more adjacent slashes is counted as a single slash. By
2796 default, `patch' strips off all leading directories, leaving just the
2799 For example, suppose the file name in the patch file is
2800 `/gnu/src/emacs/etc/NEWS'. Using `-p0' gives the entire file name
2801 unmodified, `-p1' gives `gnu/src/emacs/etc/NEWS' (no leading slash),
2802 `-p4' gives `etc/NEWS', and not specifying `-p' at all gives `NEWS'.
2804 `patch' looks for each file (after any slashes have been stripped)
2805 in the current directory, or if you used the `-d DIRECTORY' option, in
2809 File: diff.info, Node: Backups, Next: Backup Names, Prev: patch Directories, Up: Merging with patch
2814 Normally, `patch' creates a backup file if the patch does not exactly
2815 match the original input file, because in that case the original data
2816 might not be recovered if you undo the patch with `patch -R' (*note
2817 Reversed Patches::). However, when conforming to POSIX, `patch' does
2818 not create backup files by default. *Note patch and POSIX::.
2820 The `-b' or `--backup' option causes `patch' to make a backup file
2821 regardless of whether the patch matches the original input. The
2822 `--backup-if-mismatch' option causes `patch' to create backup files for
2823 mismatches files; this is the default when not conforming to POSIX. The
2824 `--no-backup-if-mismatch' option causes `patch' to not create backup
2825 files, even for mismatched patches; this is the default when conforming
2828 When backing up a file that does not exist, an empty, unreadable
2829 backup file is created as a placeholder to represent the nonexistent
2833 File: diff.info, Node: Backup Names, Next: Reject Names, Prev: Backups, Up: Merging with patch
2835 10.9 Backup File Names
2836 ======================
2838 Normally, `patch' renames an original input file into a backup file by
2839 appending to its name the extension `.orig', or `~' if using `.orig'
2840 would make the backup file name too long.(1) The `-z BACKUP-SUFFIX' or
2841 `--suffix=BACKUP-SUFFIX' option causes `patch' to use BACKUP-SUFFIX as
2842 the backup extension instead.
2844 Alternately, you can specify the extension for backup files with the
2845 `SIMPLE_BACKUP_SUFFIX' environment variable, which the options override.
2847 `patch' can also create numbered backup files the way GNU Emacs
2848 does. With this method, instead of having a single backup of each
2849 file, `patch' makes a new backup file name each time it patches a file.
2850 For example, the backups of a file named `sink' would be called,
2851 successively, `sink.~1~', `sink.~2~', `sink.~3~', etc.
2853 The `-V BACKUP-STYLE' or `--version-control=BACKUP-STYLE' option
2854 takes as an argument a method for creating backup file names. You can
2855 alternately control the type of backups that `patch' makes with the
2856 `PATCH_VERSION_CONTROL' environment variable, which the `-V' option
2857 overrides. If `PATCH_VERSION_CONTROL' is not set, the
2858 `VERSION_CONTROL' environment variable is used instead. Please note
2859 that these options and variables control backup file names; they do not
2860 affect the choice of revision control system (*note Revision Control::).
2862 The values of these environment variables and the argument to the
2863 `-V' option are like the GNU Emacs `version-control' variable (*note
2864 Backup Names: (emacs)Backup Names, for more information on backup
2865 versions in Emacs). They also recognize synonyms that are more
2866 descriptive. The valid values are listed below; unique abbreviations
2871 Always make numbered backups.
2875 Make numbered backups of files that already have them, simple
2876 backups of the others. This is the default.
2880 Always make simple backups.
2882 You can also tell `patch' to prepend a prefix, such as a directory
2883 name, to produce backup file names. The `-B PREFIX' or
2884 `--prefix=PREFIX' option makes backup files by prepending PREFIX to
2885 them. The `-Y PREFIX' or `--basename-prefix=PREFIX' prepends PREFIX to
2886 the last file name component of backup file names instead; for example,
2887 `-Y ~' causes the backup name for `dir/file.c' to be `dir/~file.c'. If
2888 you use either of these prefix options, the suffix-based options are
2891 If you specify the output file with the `-o' option, that file is
2892 the one that is backed up, not the input file.
2894 Options that affect the names of backup files do not affect whether
2895 backups are made. For example, if you specify the
2896 `--no-backup-if-mismatch' option, none of the options described in this
2897 section have any affect, because no backups are made.
2899 ---------- Footnotes ----------
2901 (1) A coding error in GNU `patch' version 2.5.4 causes it to always
2902 use `~', but this should be fixed in the next release.
2905 File: diff.info, Node: Reject Names, Next: patch Messages, Prev: Backup Names, Up: Merging with patch
2907 10.10 Reject File Names
2908 =======================
2910 The names for reject files (files containing patches that `patch' could
2911 not find a place to apply) are normally the name of the output file
2912 with `.rej' appended (or `#' if using `.rej' would make the backup file
2915 Alternatively, you can tell `patch' to place all of the rejected
2916 patches in a single file. The `-r REJECT-FILE' or
2917 `--reject-file=REJECT-FILE' option uses REJECT-FILE as the reject file
2921 File: diff.info, Node: patch Messages, Next: patch and POSIX, Prev: Reject Names, Up: Merging with patch
2923 10.11 Messages and Questions from `patch'
2924 =========================================
2926 `patch' can produce a variety of messages, especially if it has trouble
2927 decoding its input. In a few situations where it's not sure how to
2928 proceed, `patch' normally prompts you for more information from the
2929 keyboard. There are options to produce more or fewer messages, to have
2930 it not ask for keyboard input, and to affect the way that file names
2931 are quoted in messages.
2935 * More or Fewer Messages:: Controlling the verbosity of `patch'.
2936 * patch and Keyboard Input:: Inhibiting keyboard input.
2937 * patch Quoting Style:: Quoting file names in diagnostics.
2939 `patch' exits with status 0 if all hunks are applied successfully, 1
2940 if some hunks cannot be applied, and 2 if there is more serious trouble.
2941 When applying a set of patches in a loop, you should check the exit
2942 status, so you don't apply a later patch to a partially patched file.
2945 File: diff.info, Node: More or Fewer Messages, Next: patch and Keyboard Input, Up: patch Messages
2947 10.11.1 Controlling the Verbosity of `patch'
2948 --------------------------------------------
2950 You can cause `patch' to produce more messages by using the `--verbose'
2951 option. For example, when you give this option, the message `Hmm...'
2952 indicates that `patch' is reading text in the patch file, attempting to
2953 determine whether there is a patch in that text, and if so, what kind
2956 You can inhibit all terminal output from `patch', unless an error
2957 occurs, by using the `-s', `--quiet', or `--silent' option.
2960 File: diff.info, Node: patch and Keyboard Input, Next: patch Quoting Style, Prev: More or Fewer Messages, Up: patch Messages
2962 10.11.2 Inhibiting Keyboard Input
2963 ---------------------------------
2965 There are two ways you can prevent `patch' from asking you any
2966 questions. The `-f' or `--force' option assumes that you know what you
2967 are doing. It causes `patch' to do the following:
2969 * Skip patches that do not contain file names in their headers.
2971 * Patch files even though they have the wrong version for the
2972 `Prereq:' line in the patch;
2974 * Assume that patches are not reversed even if they look like they
2977 The `-t' or `--batch' option is similar to `-f', in that it suppresses
2978 questions, but it makes somewhat different assumptions:
2980 * Skip patches that do not contain file names in their headers (the
2983 * Skip patches for which the file has the wrong version for the
2984 `Prereq:' line in the patch;
2986 * Assume that patches are reversed if they look like they are.
2989 File: diff.info, Node: patch Quoting Style, Prev: patch and Keyboard Input, Up: patch Messages
2991 10.11.3 `patch' Quoting Style
2992 -----------------------------
2994 When `patch' outputs a file name in a diagnostic message, it can format
2995 the name in any of several ways. This can be useful to output file
2996 names unambiguously, even if they contain punctuation or special
2997 characters like newlines. The `--quoting-style=WORD' option controls
2998 how names are output. The WORD should be one of the following:
3004 Quote names for the shell if they contain shell metacharacters or
3005 would cause ambiguous output.
3008 Quote names for the shell, even if they would normally not require
3012 Quote names as for a C language string.
3015 Quote as with `c' except omit the surrounding double-quote
3018 You can specify the default value of the `--quoting-style' option
3019 with the environment variable `QUOTING_STYLE'. If that environment
3020 variable is not set, the default value is `shell', but this default may
3021 change in a future version of `patch'.
3024 File: diff.info, Node: patch and POSIX, Next: patch and Tradition, Prev: patch Messages, Up: Merging with patch
3026 10.12 `patch' and the POSIX Standard
3027 ====================================
3029 If you specify the `--posix' option, or set the `POSIXLY_CORRECT'
3030 environment variable, `patch' conforms more strictly to the POSIX
3031 standard, as follows:
3033 * Take the first existing file from the list (old, new, index) when
3034 intuiting file names from diff headers. *Note Multiple Patches::.
3036 * Do not remove files that are removed by a diff. *Note Creating
3039 * Do not ask whether to get files from RCS, ClearCase, or SCCS.
3040 *Note Revision Control::.
3042 * Require that all options precede the files in the command line.
3044 * Do not backup files, even when there is a mismatch. *Note
3049 File: diff.info, Node: patch and Tradition, Prev: patch and POSIX, Up: Merging with patch
3051 10.13 GNU `patch' and Traditional `patch'
3052 =========================================
3054 The current version of GNU `patch' normally follows the POSIX standard.
3055 *Note patch and POSIX::, for the few exceptions to this general rule.
3057 Unfortunately, POSIX redefined the behavior of `patch' in several
3058 important ways. You should be aware of the following differences if
3059 you must interoperate with traditional `patch', or with GNU `patch'
3060 version 2.1 and earlier.
3062 * In traditional `patch', the `-p' option's operand was optional,
3063 and a bare `-p' was equivalent to `-p0'. The `-p' option now
3064 requires an operand, and `-p 0' is now equivalent to `-p0'. For
3065 maximum compatibility, use options like `-p0' and `-p1'.
3067 Also, traditional `patch' simply counted slashes when stripping
3068 path prefixes; `patch' now counts pathname components. That is, a
3069 sequence of one or more adjacent slashes now counts as a single
3070 slash. For maximum portability, avoid sending patches containing
3073 * In traditional `patch', backups were enabled by default. This
3074 behavior is now enabled with the `-b' or `--backup' option.
3076 Conversely, in POSIX `patch', backups are never made, even when
3077 there is a mismatch. In GNU `patch', this behavior is enabled
3078 with the `--no-backup-if-mismatch' option, or by conforming to
3081 The `-b SUFFIX' option of traditional `patch' is equivalent to the
3082 `-b -z SUFFIX' options of GNU `patch'.
3084 * Traditional `patch' used a complicated (and incompletely
3085 documented) method to intuit the name of the file to be patched
3086 from the patch header. This method did not conform to POSIX, and
3087 had a few gotchas. Now `patch' uses a different, equally
3088 complicated (but better documented) method that is optionally
3089 POSIX-conforming; we hope it has fewer gotchas. The two methods
3090 are compatible if the file names in the context diff header and the
3091 `Index:' line are all identical after prefix-stripping. Your
3092 patch is normally compatible if each header's file names all
3093 contain the same number of slashes.
3095 * When traditional `patch' asked the user a question, it sent the
3096 question to standard error and looked for an answer from the first
3097 file in the following list that was a terminal: standard error,
3098 standard output, `/dev/tty', and standard input. Now `patch'
3099 sends questions to standard output and gets answers from
3100 `/dev/tty'. Defaults for some answers have been changed so that
3101 `patch' never goes into an infinite loop when using default
3104 * Traditional `patch' exited with a status value that counted the
3105 number of bad hunks, or with status 1 if there was real trouble.
3106 Now `patch' exits with status 1 if some hunks failed, or with 2 if
3107 there was real trouble.
3109 * Limit yourself to the following options when sending instructions
3110 meant to be executed by anyone running GNU `patch', traditional
3111 `patch', or a `patch' that conforms to POSIX. Spaces are
3112 significant in the following list, and operands are required.
3128 File: diff.info, Node: Making Patches, Next: Invoking cmp, Prev: Merging with patch, Up: Top
3130 11 Tips for Making and Using Patches
3131 ************************************
3133 Use some common sense when making and using patches. For example, when
3134 sending bug fixes to a program's maintainer, send several small
3135 patches, one per independent subject, instead of one large,
3136 harder-to-digest patch that covers all the subjects.
3138 Here are some other things you should keep in mind if you are going
3139 to distribute patches for updating a software package.
3143 * Tips for Patch Producers:: Advice for making patches.
3144 * Tips for Patch Consumers:: Advice for using patches.
3145 * Avoiding Common Mistakes:: Avoiding common mistakes when using `patch'.
3146 * Generating Smaller Patches:: How to generate smaller patches.
3149 File: diff.info, Node: Tips for Patch Producers, Next: Tips for Patch Consumers, Up: Making Patches
3151 11.1 Tips for Patch Producers
3152 =============================
3154 To create a patch that changes an older version of a package into a
3155 newer version, first make a copy of the older and newer versions in
3156 adjacent subdirectories. It is common to do that by unpacking `tar'
3157 archives of the two versions.
3159 To generate the patch, use the command `diff -Naur OLD NEW' where
3160 OLD and NEW identify the old and new directories. The names OLD and
3161 NEW should not contain any slashes. The `-N' option lets the patch
3162 create and remove files; `-a' lets the patch update non-text files; `-u'
3163 generates useful time stamps and enough context; and `-r' lets the
3164 patch update subdirectories. Here is an example command, using Bourne
3167 diff -Naur gcc-3.0.3 gcc-3.0.4
3169 Tell your recipients how to apply the patches. This should include
3170 which working directory to use, and which `patch' options to use; the
3171 option `-p1' is recommended. Test your procedure by pretending to be a
3172 recipient and applying your patches to a copy of the original files.
3174 *Note Avoiding Common Mistakes::, for how to avoid common mistakes
3175 when generating a patch.
3178 File: diff.info, Node: Tips for Patch Consumers, Next: Avoiding Common Mistakes, Prev: Tips for Patch Producers, Up: Making Patches
3180 11.2 Tips for Patch Consumers
3181 =============================
3183 A patch producer should tell recipients how to apply the patches, so
3184 the first rule of thumb for a patch consumer is to follow the
3185 instructions supplied with the patch.
3187 GNU `diff' can analyze files with arbitrarily long lines and files
3188 that end in incomplete lines. However, older versions of `patch'
3189 cannot patch such files. If you are having trouble applying such
3190 patches, try upgrading to a recent version of GNU `patch'.
3193 File: diff.info, Node: Avoiding Common Mistakes, Next: Generating Smaller Patches, Prev: Tips for Patch Consumers, Up: Making Patches
3195 11.3 Avoiding Common Mistakes
3196 =============================
3198 When producing a patch for multiple files, apply `diff' to directories
3199 whose names do not have slashes. This reduces confusion when the patch
3200 consumer specifies the `-pNUMBER' option, since this option can have
3201 surprising results when the old and new file names have different
3202 numbers of slashes. For example, do not send a patch with a header
3203 that looks like this:
3205 diff -Naur v2.0.29/prog/README prog/README
3206 --- v2.0.29/prog/README 2002-03-10 23:30:39.942229878 -0800
3207 +++ prog/README 2002-03-17 20:49:32.442260588 -0800
3209 because the two file names have different numbers of slashes, and
3210 different versions of `patch' interpret the file names differently. To
3211 avoid confusion, send output that looks like this instead:
3213 diff -Naur v2.0.29/prog/README v2.0.30/prog/README
3214 --- v2.0.29/prog/README 2002-03-10 23:30:39.942229878 -0800
3215 +++ v2.0.30/prog/README 2002-03-17 20:49:32.442260588 -0800
3217 Make sure you have specified the file names correctly, either in a
3218 context diff header or with an `Index:' line. Take care to not send out
3219 reversed patches, since these make people wonder whether they have
3220 already applied the patch.
3222 Avoid sending patches that compare backup file names like
3223 `README.orig' or `README~', since this might confuse `patch' into
3224 patching a backup file instead of the real file. Instead, send patches
3225 that compare the same base file names in different directories, e.g.
3226 `old/README' and `new/README'.
3228 To save people from partially applying a patch before other patches
3229 that should have gone before it, you can make the first patch in the
3230 patch file update a file with a name like `patchlevel.h' or
3231 `version.c', which contains a patch level or version number. If the
3232 input file contains the wrong version number, `patch' will complain
3235 An even clearer way to prevent this problem is to put a `Prereq:'
3236 line before the patch. If the leading text in the patch file contains a
3237 line that starts with `Prereq:', `patch' takes the next word from that
3238 line (normally a version number) and checks whether the next input file
3239 contains that word, preceded and followed by either white space or a
3240 newline. If not, `patch' prompts you for confirmation before
3241 proceeding. This makes it difficult to accidentally apply patches in
3245 File: diff.info, Node: Generating Smaller Patches, Prev: Avoiding Common Mistakes, Up: Making Patches
3247 11.4 Generating Smaller Patches
3248 ===============================
3250 The simplest way to generate a patch is to use `diff -Naur' (*note Tips
3251 for Patch Producers::), but you might be able to reduce the size of the
3252 patch by renaming or removing some files before making the patch. If
3253 the older version of the package contains any files that the newer
3254 version does not, or if any files have been renamed between the two
3255 versions, make a list of `rm' and `mv' commands for the user to execute
3256 in the old version directory before applying the patch. Then run those
3257 commands yourself in the scratch directory.
3259 If there are any files that you don't need to include in the patch
3260 because they can easily be rebuilt from other files (for example,
3261 `TAGS' and output from `yacc' and `makeinfo'), exclude them from the
3262 patch by giving `diff' the `-x PATTERN' option (*note Comparing
3263 Directories::). If you want your patch to modify a derived file
3264 because your recipients lack tools to build it, make sure that the
3265 patch for the derived file follows any patches for files that it
3266 depends on, so that the recipients' time stamps will not confuse `make'.
3268 Now you can create the patch using `diff -Naur'. Make sure to
3269 specify the scratch directory first and the newer directory second.
3271 Add to the top of the patch a note telling the user any `rm' and
3272 `mv' commands to run before applying the patch. Then you can remove
3273 the scratch directory.
3275 You can also shrink the patch size by using fewer lines of context,
3276 but bear in mind that `patch' typically needs at least two lines for
3277 proper operation when patches do not exactly match the input files.
3280 File: diff.info, Node: Invoking cmp, Next: Invoking diff, Prev: Making Patches, Up: Top
3285 The `cmp' command compares two files, and if they differ, tells the
3286 first byte and line number where they differ or reports that one file
3287 is a prefix of the other. Bytes and lines are numbered starting with
3288 1. The arguments of `cmp' are as follows:
3290 cmp OPTIONS... FROM-FILE [TO-FILE [FROM-SKIP [TO-SKIP]]]
3292 The file name `-' is always the standard input. `cmp' also uses the
3293 standard input if one file name is omitted. The FROM-SKIP and TO-SKIP
3294 operands specify how many bytes to ignore at the start of each file;
3295 they are equivalent to the `--ignore-initial=FROM-SKIP:TO-SKIP' option.
3297 By default, `cmp' outputs nothing if the two files have the same
3298 contents. If one file is a prefix of the other, `cmp' prints to
3299 standard error a message of the following form:
3301 cmp: EOF on SHORTER-FILE
3303 Otherwise, `cmp' prints to standard output a message of the
3306 FROM-FILE TO-FILE differ: char BYTE-NUMBER, line LINE-NUMBER
3308 The message formats can differ outside the POSIX locale. Also,
3309 POSIX allows the EOF message to be followed by a blank and some
3310 additional information.
3312 An exit status of 0 means no differences were found, 1 means some
3313 differences were found, and 2 means trouble.
3317 * cmp Options:: Summary of options to `cmp'.
3320 File: diff.info, Node: cmp Options, Up: Invoking cmp
3322 12.1 Options to `cmp'
3323 =====================
3325 Below is a summary of all of the options that GNU `cmp' accepts. Most
3326 options have two equivalent names, one of which is a single letter
3327 preceded by `-', and the other of which is a long name preceded by
3328 `--'. Multiple single letter options (unless they take an argument)
3329 can be combined into a single command line word: `-bl' is equivalent to
3334 Print the differing bytes. Display control bytes as a `^'
3335 followed by a letter of the alphabet and precede bytes that have
3336 the high bit set with `M-' (which stands for "meta").
3339 Output a summary of usage and then exit.
3342 `--ignore-initial=SKIP'
3343 Ignore any differences in the first SKIP bytes of the input files.
3344 Treat files with fewer than SKIP bytes as if they are empty. If
3345 SKIP is of the form `FROM-SKIP:TO-SKIP', skip the first FROM-SKIP
3346 bytes of the first input file and the first TO-SKIP bytes of the
3351 Output the (decimal) byte numbers and (octal) values of all
3352 differing bytes, instead of the default standard output.
3356 Compare at most COUNT input bytes.
3361 Do not print anything; only return an exit status indicating
3362 whether the files differ.
3366 Output version information and then exit.
3368 In the above table, operands that are byte counts are normally
3369 decimal, but may be preceded by `0' for octal and `0x' for hexadecimal.
3371 A byte count can be followed by a suffix to specify a multiple of
3372 that count; in this case an omitted integer is understood to be 1. A
3373 bare size letter, or one followed by `iB', specifies a multiple using
3374 powers of 1024. A size letter followed by `B' specifies powers of 1000
3375 instead. For example, `-n 4M' and `-n 4MiB' are equivalent to `-n
3376 4194304', whereas `-n 4MB' is equivalent to `-n 4000000'. This
3377 notation is upward compatible with the SI prefixes
3378 (http://www.bipm.fr/enus/3_SI/si-prefixes.html) for decimal multiples
3379 and with the IEC 60027-2 prefixes for binary multiples
3380 (http://physics.nist.gov/cuu/Units/binary.html).
3382 The following suffixes are defined. Large sizes like `1Y' may be
3383 rejected by your computer due to limitations of its arithmetic.
3386 kilobyte: 10^3 = 1000.
3391 kibibyte: 2^10 = 1024. `K' is special: the SI prefix is `k' and
3392 the IEC 60027-2 prefix is `Ki', but tradition and POSIX use `k' to
3396 megabyte: 10^6 = 1,000,000.
3400 mebibyte: 2^20 = 1,048,576.
3403 gigabyte: 10^9 = 1,000,000,000.
3407 gibibyte: 2^30 = 1,073,741,824.
3410 terabyte: 10^12 = 1,000,000,000,000.
3414 tebibyte: 2^40 = 1,099,511,627,776.
3417 petabyte: 10^15 = 1,000,000,000,000,000.
3421 pebibyte: 2^50 = 1,125,899,906,842,624.
3424 exabyte: 10^18 = 1,000,000,000,000,000,000.
3428 exbibyte: 2^60 = 1,152,921,504,606,846,976.
3431 zettabyte: 10^21 = 1,000,000,000,000,000,000,000
3435 2^70 = 1,180,591,620,717,411,303,424. (`Zi' is a GNU extension to
3439 yottabyte: 10^24 = 1,000,000,000,000,000,000,000,000.
3443 2^80 = 1,208,925,819,614,629,174,706,176. (`Yi' is a GNU
3444 extension to IEC 60027-2.)
3447 File: diff.info, Node: Invoking diff, Next: Invoking diff3, Prev: Invoking cmp, Up: Top
3452 The format for running the `diff' command is:
3454 diff OPTIONS... FILES...
3456 In the simplest case, two file names FROM-FILE and TO-FILE are
3457 given, and `diff' compares the contents of FROM-FILE and TO-FILE. A
3458 file name of `-' stands for text read from the standard input. As a
3459 special case, `diff - -' compares a copy of standard input to itself.
3461 If one file is a directory and the other is not, `diff' compares the
3462 file in the directory whose name is that of the non-directory. The
3463 non-directory file must not be `-'.
3465 If two file names are given and both are directories, `diff'
3466 compares corresponding files in both directories, in alphabetical
3467 order; this comparison is not recursive unless the `-r' or
3468 `--recursive' option is given. `diff' never compares the actual
3469 contents of a directory as if it were a file. The file that is fully
3470 specified may not be standard input, because standard input is nameless
3471 and the notion of "file with the same name" does not apply.
3473 If the `--from-file=FILE' option is given, the number of file names
3474 is arbitrary, and FILE is compared to each named file. Similarly, if
3475 the `--to-file=FILE' option is given, each named file is compared to
3478 `diff' options begin with `-', so normally file names may not begin
3479 with `-'. However, `--' as an argument by itself treats the remaining
3480 arguments as file names even if they begin with `-'.
3482 An exit status of 0 means no differences were found, 1 means some
3483 differences were found, and 2 means trouble. Normally, differing
3484 binary files count as trouble, but this can be altered by using the
3485 `-a' or `--text' option, or the `-q' or `--brief' option.
3489 * diff Options:: Summary of options to `diff'.
3492 File: diff.info, Node: diff Options, Up: Invoking diff
3494 13.1 Options to `diff'
3495 ======================
3497 Below is a summary of all of the options that GNU `diff' accepts. Most
3498 options have two equivalent names, one of which is a single letter
3499 preceded by `-', and the other of which is a long name preceded by
3500 `--'. Multiple single letter options (unless they take an argument)
3501 can be combined into a single command line word: `-ac' is equivalent to
3502 `-a -c'. Long named options can be abbreviated to any unique prefix of
3503 their name. Brackets ([ and ]) indicate that an option takes an
3508 Treat all files as text and compare them line-by-line, even if they
3509 do not seem to be text. *Note Binary::.
3512 `--ignore-space-change'
3513 Ignore changes in amount of white space. *Note White Space::.
3516 `--ignore-blank-lines'
3517 Ignore changes that just insert or delete blank lines. *Note
3521 Read and write data in binary mode. *Note Binary::.
3524 Use the context output format, showing three lines of context.
3525 *Note Context Format::.
3529 Use the context output format, showing LINES (an integer) lines of
3530 context, or three if LINES is not given. *Note Context Format::.
3531 For proper operation, `patch' typically needs at least two lines of
3534 On older systems, `diff' supports an obsolete option `-LINES' that
3535 has effect when combined with `-c' or `-p'. POSIX 1003.1-2001
3536 (*note Standards conformance::) does not allow this; use `-C LINES'
3539 `--changed-group-format=FORMAT'
3540 Use FORMAT to output a line group containing differing lines from
3541 both files in if-then-else format. *Note Line Group Formats::.
3545 Change the algorithm perhaps find a smaller set of changes. This
3546 makes `diff' slower (sometimes much slower). *Note diff
3551 Make merged `#ifdef' format output, conditional on the preprocessor
3552 macro NAME. *Note If-then-else::.
3556 Make output that is a valid `ed' script. *Note ed Scripts::.
3559 `--ignore-tab-expansion'
3560 Ignore changes due to tab expansion. *Note White Space::.
3564 Make output that looks vaguely like an `ed' script but has changes
3565 in the order they appear in the file. *Note Forward ed::.
3568 `--show-function-line=REGEXP'
3569 In context and unified format, for each hunk of differences, show
3570 some of the last preceding line that matches REGEXP. *Note
3571 Specified Headings::.
3574 Compare FILE to each operand; FILE may be a directory.
3577 Output a summary of usage and then exit.
3579 `--horizon-lines=LINES'
3580 Do not discard the last LINES lines of the common prefix and the
3581 first LINES lines of the common suffix. *Note diff Performance::.
3585 Ignore changes in case; consider upper- and lower-case letters
3586 equivalent. *Note Case Folding::.
3589 `--ignore-matching-lines=REGEXP'
3590 Ignore changes that just insert or delete lines that match REGEXP.
3591 *Note Specified Lines::.
3593 `--ignore-file-name-case'
3594 Ignore case when comparing file names during recursive comparison.
3595 *Note Comparing Directories::.
3599 Pass the output through `pr' to paginate it. *Note Pagination::.
3602 Use LABEL instead of the file name in the context format (*note
3603 Context Format::) and unified format (*note Unified Format::)
3604 headers. *Note RCS::.
3607 Print only the left column of two common lines in side by side
3608 format. *Note Side by Side Format::.
3610 `--line-format=FORMAT'
3611 Use FORMAT to output all input lines in if-then-else format.
3612 *Note Line Formats::.
3616 Output RCS-format diffs; like `-f' except that each command
3617 specifies the number of lines affected. *Note RCS::.
3621 In directory comparison, if a file is found in only one directory,
3622 treat it as present but empty in the other directory. *Note
3623 Comparing Directories::.
3625 `--new-group-format=FORMAT'
3626 Use FORMAT to output a group of lines taken from just the second
3627 file in if-then-else format. *Note Line Group Formats::.
3629 `--new-line-format=FORMAT'
3630 Use FORMAT to output a line taken from just the second file in
3631 if-then-else format. *Note Line Formats::.
3633 `--old-group-format=FORMAT'
3634 Use FORMAT to output a group of lines taken from just the first
3635 file in if-then-else format. *Note Line Group Formats::.
3637 `--old-line-format=FORMAT'
3638 Use FORMAT to output a line taken from just the first file in
3639 if-then-else format. *Note Line Formats::.
3643 Show which C function each change is in. *Note C Function
3648 Report only whether the files differ, not the details of the
3649 differences. *Note Brief::.
3653 When comparing directories, recursively compare any subdirectories
3654 found. *Note Comparing Directories::.
3657 `--report-identical-files'
3658 Report when two files are the same. *Note Comparing Directories::.
3661 `--starting-file=FILE'
3662 When comparing directories, start with the file FILE. This is
3663 used for resuming an aborted comparison. *Note Comparing
3666 `--speed-large-files'
3667 Use heuristics to speed handling of large files that have numerous
3668 scattered small changes. *Note diff Performance::.
3670 `--strip-trailing-cr'
3671 Strip any trailing carriage return at the end of an input line.
3674 `--suppress-common-lines'
3675 Do not print common lines in side by side format. *Note Side by
3680 Expand tabs to spaces in the output, to preserve the alignment of
3681 tabs in the input files. *Note Tabs::.
3685 Output a tab rather than a space before the text of a line in
3686 normal or context format. This causes the alignment of tabs in
3687 the line to look normal. *Note Tabs::.
3690 Assume that tab stops are set every COLUMNS (default 8) print
3691 columns. *Note Tabs::.
3694 Compare each operand to FILE; FILE may be a directory.
3697 Use the unified output format, showing three lines of context.
3698 *Note Unified Format::.
3700 `--unchanged-group-format=FORMAT'
3701 Use FORMAT to output a group of common lines taken from both files
3702 in if-then-else format. *Note Line Group Formats::.
3704 `--unchanged-line-format=FORMAT'
3705 Use FORMAT to output a line common to both files in if-then-else
3706 format. *Note Line Formats::.
3708 `--unidirectional-new-file'
3709 When comparing directories, if a file appears only in the second
3710 directory of the two, treat it as present but empty in the other.
3711 *Note Comparing Directories::.
3715 Use the unified output format, showing LINES (an integer) lines of
3716 context, or three if LINES is not given. *Note Unified Format::.
3717 For proper operation, `patch' typically needs at least two lines of
3720 On older systems, `diff' supports an obsolete option `-LINES' that
3721 has effect when combined with `-u'. POSIX 1003.1-2001 (*note
3722 Standards conformance::) does not allow this; use `-U LINES'
3727 Output version information and then exit.
3730 `--ignore-all-space'
3731 Ignore white space when comparing lines. *Note White Space::.
3735 Output at most COLUMNS (default 130) print columns per line in
3736 side by side format. *Note Side by Side Format::.
3740 When comparing directories, ignore files and subdirectories whose
3741 basenames match PATTERN. *Note Comparing Directories::.
3744 `--exclude-from=FILE'
3745 When comparing directories, ignore files and subdirectories whose
3746 basenames match any pattern contained in FILE. *Note Comparing
3751 Use the side by side output format. *Note Side by Side Format::.
3754 File: diff.info, Node: Invoking diff3, Next: Invoking patch, Prev: Invoking diff, Up: Top
3759 The `diff3' command compares three files and outputs descriptions of
3760 their differences. Its arguments are as follows:
3762 diff3 OPTIONS... MINE OLDER YOURS
3764 The files to compare are MINE, OLDER, and YOURS. At most one of
3765 these three file names may be `-', which tells `diff3' to read the
3766 standard input for that file.
3768 An exit status of 0 means `diff3' was successful, 1 means some
3769 conflicts were found, and 2 means trouble.
3773 * diff3 Options:: Summary of options to `diff3'.
3776 File: diff.info, Node: diff3 Options, Up: Invoking diff3
3778 14.1 Options to `diff3'
3779 =======================
3781 Below is a summary of all of the options that GNU `diff3' accepts.
3782 Multiple single letter options (unless they take an argument) can be
3783 combined into a single command line argument.
3787 Treat all files as text and compare them line-by-line, even if they
3788 do not appear to be text. *Note Binary::.
3792 Incorporate all unmerged changes from OLDER to YOURS into MINE,
3793 surrounding conflicts with bracket lines. *Note Marking
3796 `--diff-program=PROGRAM'
3797 Use the compatible comparison program PROGRAM to compare files
3802 Generate an `ed' script that incorporates all the changes from
3803 OLDER to YOURS into MINE. *Note Which Changes::.
3807 Like `-e', except bracket lines from overlapping changes' first
3808 and third files. *Note Marking Conflicts::. With `-E', an
3809 overlapping change looks like this:
3818 Output a summary of usage and then exit.
3821 Generate `w' and `q' commands at the end of the `ed' script for
3822 System V compatibility. This option must be combined with one of
3823 the `-AeExX3' options, and may not be combined with `-m'. *Note
3824 Saving the Changed File::.
3827 Use the label LABEL for the brackets output by the `-A', `-E' and
3828 `-X' options. This option may be given up to three times, one for
3829 each input file. The default labels are the names of the input
3830 files. Thus `diff3 --label X --label Y --label Z -m A B C' acts
3831 like `diff3 -m A B C', except that the output looks like it came
3832 from files named `X', `Y' and `Z' rather than from files named
3833 `A', `B' and `C'. *Note Marking Conflicts::.
3837 Apply the edit script to the first file and send the result to
3838 standard output. Unlike piping the output from `diff3' to `ed',
3839 this works even for binary files and incomplete lines. `-A' is
3840 assumed if no edit script option is specified. *Note Bypassing
3843 `--strip-trailing-cr'
3844 Strip any trailing carriage return at the end of an input line.
3849 Output a tab rather than two spaces before the text of a line in
3850 normal format. This causes the alignment of tabs in the line to
3851 look normal. *Note Tabs::.
3855 Output version information and then exit.
3859 Like `-e', except output only the overlapping changes. *Note
3863 Like `-E', except output only the overlapping changes. In other
3864 words, like `-x', except bracket changes as in `-E'. *Note
3865 Marking Conflicts::.
3869 Like `-e', except output only the nonoverlapping changes. *Note
3873 File: diff.info, Node: Invoking patch, Next: Invoking sdiff, Prev: Invoking diff3, Up: Top
3878 Normally `patch' is invoked like this:
3882 The full format for invoking `patch' is:
3884 patch OPTIONS... [ORIGFILE [PATCHFILE]]
3886 You can also specify where to read the patch from with the `-i
3887 PATCHFILE' or `--input=PATCHFILE' option. If you do not specify
3888 PATCHFILE, or if PATCHFILE is `-', `patch' reads the patch (that is,
3889 the `diff' output) from the standard input.
3891 If you do not specify an input file on the command line, `patch'
3892 tries to intuit from the "leading text" (any text in the patch that
3893 comes before the `diff' output) which file to edit. *Note Multiple
3896 By default, `patch' replaces the original input file with the
3897 patched version, possibly after renaming the original file into a
3898 backup file (*note Backup Names::, for a description of how `patch'
3899 names backup files). You can also specify where to put the output with
3900 the `-o FILE' or `--output=FILE' option; however, do not use this option
3901 if FILE is one of the input files.
3905 * patch Options:: Summary table of options to `patch'.
3908 File: diff.info, Node: patch Options, Up: Invoking patch
3910 15.1 Options to `patch'
3911 =======================
3913 Here is a summary of all of the options that GNU `patch' accepts.
3914 *Note patch and Tradition::, for which of these options are safe to use
3915 in older versions of `patch'.
3917 Multiple single-letter options that do not take an argument can be
3918 combined into a single command line argument with only one dash.
3922 Back up the original contents of each file, even if backups would
3923 normally not be made. *Note Backups::.
3927 Prepend PREFIX to backup file names. *Note Backup Names::.
3929 `--backup-if-mismatch'
3930 Back up the original contents of each file if the patch does not
3931 exactly match the file. This is the default behavior when not
3932 conforming to POSIX. *Note Backups::.
3935 Read and write all files in binary mode, except for standard output
3936 and `/dev/tty'. This option has no effect on POSIX-conforming
3937 systems like GNU/Linux. On systems where this option makes a
3938 difference, the patch should be generated by `diff -a --binary'.
3943 Interpret the patch file as a context diff. *Note patch Input::.
3946 `--directory=DIRECTORY'
3947 Make directory DIRECTORY the current directory for interpreting
3948 both file names in the patch file, and file names given as
3949 arguments to other options. *Note patch Directories::.
3953 Make merged if-then-else output using NAME. *Note If-then-else::.
3956 Print the results of applying the patches without actually changing
3957 any files. *Note Dry Runs::.
3961 Interpret the patch file as an `ed' script. *Note patch Input::.
3964 `--remove-empty-files'
3965 Remove output files that are empty after the patches have been
3966 applied. *Note Creating and Removing::.
3970 Assume that the user knows exactly what he or she is doing, and do
3971 not ask any questions. *Note patch Messages::.
3975 Set the maximum fuzz factor to LINES. *Note Inexact::.
3979 If NUM is positive, get input files from a revision control system
3980 as necessary; if zero, do not get the files; if negative, ask the
3981 user whether to get the files. *Note Revision Control::.
3984 Output a summary of usage and then exit.
3988 Read the patch from PATCHFILE rather than from standard input.
3989 *Note patch Options::.
3992 `--ignore-white-space'
3993 Let any sequence of blanks (spaces or tabs) in the patch file match
3994 any sequence of blanks in the input file. *Note Changed White
3999 Interpret the patch file as a normal diff. *Note patch Input::.
4003 Ignore patches that `patch' thinks are reversed or already applied.
4004 See also `-R'. *Note Reversed Patches::.
4006 `--no-backup-if-mismatch'
4007 Do not back up the original contents of files. This is the default
4008 behavior when conforming to POSIX. *Note Backups::.
4012 Use FILE as the output file name. *Note patch Options::.
4016 Set the file name strip count to NUMBER. *Note patch
4020 Conform to POSIX, as if the `POSIXLY_CORRECT' environment variable
4021 had been set. *Note patch and POSIX::.
4023 `--quoting-style=WORD'
4024 Use style WORD to quote names in diagnostics, as if the
4025 `QUOTING_STYLE' environment variable had been set to WORD. *Note
4026 patch Quoting Style::.
4029 `--reject-file=REJECT-FILE'
4030 Use REJECT-FILE as the reject file name. *Note Reject Names::.
4034 Assume that this patch was created with the old and new files
4035 swapped. *Note Reversed Patches::.
4040 Work silently unless an error occurs. *Note patch Messages::.
4044 Do not ask any questions. *Note patch Messages::.
4048 Set the modification and access times of patched files from time
4049 stamps given in context diff headers, assuming that the context
4050 diff headers use local time. *Note Patching Time Stamps::.
4054 Interpret the patch file as a unified diff. *Note patch Input::.
4058 Output version information and then exit.
4061 `--version=control=BACKUP-STYLE'
4062 Select the naming convention for backup file names. *Note Backup
4066 Print more diagnostics than usual. *Note patch Messages::.
4070 Set internal debugging flags. Of interest only to `patch'
4074 `--basename-prefix=PREFIX'
4075 Prepend PREFIX to base names of backup files. *Note Backup
4080 Use SUFFIX as the backup extension instead of `.orig' or `~'.
4081 *Note Backup Names::.
4085 Set the modification and access times of patched files from time
4086 stamps given in context diff headers, assuming that the context
4087 diff headers use UTC. *Note Patching Time Stamps::.
4091 File: diff.info, Node: Invoking sdiff, Next: Standards conformance, Prev: Invoking patch, Up: Top
4096 The `sdiff' command merges two files and interactively outputs the
4097 results. Its arguments are as follows:
4099 sdiff -o OUTFILE OPTIONS... FROM-FILE TO-FILE
4101 This merges FROM-FILE with TO-FILE, with output to OUTFILE. If
4102 FROM-FILE is a directory and TO-FILE is not, `sdiff' compares the file
4103 in FROM-FILE whose file name is that of TO-FILE, and vice versa.
4104 FROM-FILE and TO-FILE may not both be directories.
4106 `sdiff' options begin with `-', so normally FROM-FILE and TO-FILE
4107 may not begin with `-'. However, `--' as an argument by itself treats
4108 the remaining arguments as file names even if they begin with `-'. You
4109 may not use `-' as an input file.
4111 `sdiff' without `-o' (or `--output') produces a side-by-side
4112 difference. This usage is obsolete; use the `-y' or `--side-by-side'
4113 option of `diff' instead.
4115 An exit status of 0 means no differences were found, 1 means some
4116 differences were found, and 2 means trouble.
4120 * sdiff Options:: Summary of options to `diff'.
4123 File: diff.info, Node: sdiff Options, Up: Invoking sdiff
4125 16.1 Options to `sdiff'
4126 =======================
4128 Below is a summary of all of the options that GNU `sdiff' accepts.
4129 Each option has two equivalent names, one of which is a single letter
4130 preceded by `-', and the other of which is a long name preceded by
4131 `--'. Multiple single letter options (unless they take an argument)
4132 can be combined into a single command line argument. Long named
4133 options can be abbreviated to any unique prefix of their name.
4137 Treat all files as text and compare them line-by-line, even if they
4138 do not appear to be text. *Note Binary::.
4141 `--ignore-space-change'
4142 Ignore changes in amount of white space. *Note White Space::.
4145 `--ignore-blank-lines'
4146 Ignore changes that just insert or delete blank lines. *Note
4151 Change the algorithm to perhaps find a smaller set of changes.
4152 This makes `sdiff' slower (sometimes much slower). *Note diff
4155 `--diff-program=PROGRAM'
4156 Use the compatible comparison program PROGRAM to compare files
4160 `--ignore-tab-expansion'
4161 Ignore changes due to tab expansion. *Note White Space::.
4164 Output a summary of usage and then exit.
4168 Ignore changes in case; consider upper- and lower-case to be the
4169 same. *Note Case Folding::.
4172 `--ignore-matching-lines=REGEXP'
4173 Ignore changes that just insert or delete lines that match REGEXP.
4174 *Note Specified Lines::.
4178 Print only the left column of two common lines. *Note Side by
4183 Put merged output into FILE. This option is required for merging.
4186 `--suppress-common-lines'
4187 Do not print common lines. *Note Side by Side Format::.
4189 `--speed-large-files'
4190 Use heuristics to speed handling of large files that have numerous
4191 scattered small changes. *Note diff Performance::.
4193 `--strip-trailing-cr'
4194 Strip any trailing carriage return at the end of an input line.
4199 Expand tabs to spaces in the output, to preserve the alignment of
4200 tabs in the input files. *Note Tabs::.
4203 Assume that tab stops are set every COLUMNS (default 8) print
4204 columns. *Note Tabs::.
4208 Output version information and then exit.
4212 Output at most COLUMNS (default 130) print columns per line.
4213 *Note Side by Side Format::. Note that for historical reasons,
4214 this option is `-W' in `diff', `-w' in `sdiff'.
4217 `--ignore-all-space'
4218 Ignore white space when comparing lines. *Note White Space::.
4219 Note that for historical reasons, this option is `-w' in `diff',
4223 File: diff.info, Node: Standards conformance, Next: Projects, Prev: Invoking sdiff, Up: Top
4225 17 Standards conformance
4226 ************************
4228 In a few cases, the GNU utilities' default behavior is incompatible
4229 with the POSIX standard. To suppress these incompatibilities, define
4230 the `POSIXLY_CORRECT' environment variable. Unless you are checking
4231 for POSIX conformance, you probably do not need to define
4234 Normally options and operands can appear in any order, and programs
4235 act as if all the options appear before any operands. For example,
4236 `diff lao tzu -C 2' acts like `diff -C 2 lao tzu', since `2' is an
4237 option-argument of `-C'. However, if the `POSIXLY_CORRECT' environment
4238 variable is set, options must appear before operands, unless otherwise
4239 specified for a particular command.
4241 Newer versions of POSIX are occasionally incompatible with older
4242 versions. For example, older versions of POSIX allowed the command
4243 `diff -c -10' to have the same meaning as `diff -C 10', but POSIX
4244 1003.1-2001 `diff' no longer allows digit-string options like `-10'.
4246 The GNU utilities normally conform to the version of POSIX that is
4247 standard for your system. To cause them to conform to a different
4248 version of POSIX, define the `_POSIX2_VERSION' environment variable to
4249 a value of the form YYYYMM specifying the year and month the standard
4250 was adopted. Two values are currently supported for `_POSIX2_VERSION':
4251 `199209' stands for POSIX 1003.2-1992, and `200112' stands for POSIX
4252 1003.1-2001. For example, if you are running older software that
4253 assumes an older version of POSIX and uses `diff -c -10', you can work
4254 around the compatibility problems by setting `_POSIX2_VERSION=199209'
4255 in your environment.
4258 File: diff.info, Node: Projects, Next: Copying This Manual, Prev: Standards conformance, Up: Top
4263 Here are some ideas for improving GNU `diff' and `patch'. The GNU
4264 project has identified some improvements as potential programming
4265 projects for volunteers. You can also help by reporting any bugs that
4268 If you are a programmer and would like to contribute something to the
4269 GNU project, please consider volunteering for one of these projects.
4270 If you are seriously contemplating work, please write to <gvc@gnu.org>
4271 to coordinate with other volunteers.
4275 * Shortcomings:: Suggested projects for improvements.
4276 * Bugs:: Reporting bugs.
4279 File: diff.info, Node: Shortcomings, Next: Bugs, Up: Projects
4281 18.1 Suggested Projects for Improving GNU `diff' and `patch'
4282 ============================================================
4284 One should be able to use GNU `diff' to generate a patch from any pair
4285 of directory trees, and given the patch and a copy of one such tree,
4286 use `patch' to generate a faithful copy of the other. Unfortunately,
4287 some changes to directory trees cannot be expressed using current patch
4288 formats; also, `patch' does not handle some of the existing formats.
4289 These shortcomings motivate the following suggested projects.
4293 * Internationalization:: Handling multibyte and varying-width characters.
4294 * Changing Structure:: Handling changes to the directory structure.
4295 * Special Files:: Handling symbolic links, device special files, etc.
4296 * Unusual File Names:: Handling file names that contain unusual characters.
4297 * Time Stamp Order:: Outputting diffs in time stamp order.
4298 * Ignoring Changes:: Ignoring certain changes while showing others.
4299 * Speedups:: Improving performance.
4302 File: diff.info, Node: Internationalization, Next: Changing Structure, Up: Shortcomings
4304 18.1.1 Handling Multibyte and Varying-Width Characters
4305 ------------------------------------------------------
4307 `diff', `diff3' and `sdiff' treat each line of input as a string of
4308 unibyte characters. This can mishandle multibyte characters in some
4309 cases. For example, when asked to ignore spaces, `diff' does not
4310 properly ignore a multibyte space character.
4312 Also, `diff' currently assumes that each byte is one column wide,
4313 and this assumption is incorrect in some locales, e.g., locales that
4314 use UTF-8 encoding. This causes problems with the `-y' or
4315 `--side-by-side' option of `diff'.
4317 These problems need to be fixed without unduly affecting the
4318 performance of the utilities in unibyte environments.
4320 The IBM GNU/Linux Technology Center Internationalization Team has
4321 proposed patches to support internationalized `diff'
4322 (http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.patch.gz).
4323 Unfortunately, these patches are incomplete and are to an older version
4324 of `diff', so more work needs to be done in this area.
4327 File: diff.info, Node: Changing Structure, Next: Special Files, Prev: Internationalization, Up: Shortcomings
4329 18.1.2 Handling Changes to the Directory Structure
4330 --------------------------------------------------
4332 `diff' and `patch' do not handle some changes to directory structure.
4333 For example, suppose one directory tree contains a directory named `D'
4334 with some subsidiary files, and another contains a file with the same
4335 name `D'. `diff -r' does not output enough information for `patch' to
4336 transform the directory subtree into the file.
4338 There should be a way to specify that a file has been removed without
4339 having to include its entire contents in the patch file. There should
4340 also be a way to tell `patch' that a file was renamed, even if there is
4341 no way for `diff' to generate such information. There should be a way
4342 to tell `patch' that a file's time stamp has changed, even if its
4343 contents have not changed.
4345 These problems can be fixed by extending the `diff' output format to
4346 represent changes in directory structure, and extending `patch' to
4347 understand these extensions.
4350 File: diff.info, Node: Special Files, Next: Unusual File Names, Prev: Changing Structure, Up: Shortcomings
4352 18.1.3 Files that are Neither Directories Nor Regular Files
4353 -----------------------------------------------------------
4355 Some files are neither directories nor regular files: they are unusual
4356 files like symbolic links, device special files, named pipes, and
4357 sockets. Currently, `diff' treats symbolic links as if they were the
4358 pointed-to files, except that a recursive `diff' reports an error if it
4359 detects infinite loops of symbolic links (e.g., symbolic links to
4360 `..'). `diff' treats other special files like regular files if they
4361 are specified at the top level, but simply reports their presence when
4362 comparing directories. This means that `patch' cannot represent
4363 changes to such files. For example, if you change which file a
4364 symbolic link points to, `diff' outputs the difference between the two
4365 files, instead of the change to the symbolic link.
4367 `diff' should optionally report changes to special files specially,
4368 and `patch' should be extended to understand these extensions.
4371 File: diff.info, Node: Unusual File Names, Next: Time Stamp Order, Prev: Special Files, Up: Shortcomings
4373 18.1.4 File Names that Contain Unusual Characters
4374 -------------------------------------------------
4376 When a file name contains an unusual character like a newline or white
4377 space, `diff -r' generates a patch that `patch' cannot parse. The
4378 problem is with format of `diff' output, not just with `patch', because
4379 with odd enough file names one can cause `diff' to generate a patch
4380 that is syntactically correct but patches the wrong files. The format
4381 of `diff' output should be extended to handle all possible file names.
4384 File: diff.info, Node: Time Stamp Order, Next: Ignoring Changes, Prev: Unusual File Names, Up: Shortcomings
4386 18.1.5 Outputting Diffs in Time Stamp Order
4387 -------------------------------------------
4389 Applying `patch' to a multiple-file diff can result in files whose time
4390 stamps are out of order. GNU `patch' has options to restore the time
4391 stamps of the updated files (*note Patching Time Stamps::), but
4392 sometimes it is useful to generate a patch that works even if the
4393 recipient does not have GNU patch, or does not use these options. One
4394 way to do this would be to implement a `diff' option to output diffs in
4398 File: diff.info, Node: Ignoring Changes, Next: Speedups, Prev: Time Stamp Order, Up: Shortcomings
4400 18.1.6 Ignoring Certain Changes
4401 -------------------------------
4403 It would be nice to have a feature for specifying two strings, one in
4404 FROM-FILE and one in TO-FILE, which should be considered to match.
4405 Thus, if the two strings are `foo' and `bar', then if two lines differ
4406 only in that `foo' in file 1 corresponds to `bar' in file 2, the lines
4407 are treated as identical.
4409 It is not clear how general this feature can or should be, or what
4410 syntax should be used for it.
4412 A partial substitute is to filter one or both files before comparing,
4415 sed 's/foo/bar/g' file1 | diff - file2
4417 However, this outputs the filtered text, not the original.
4420 File: diff.info, Node: Speedups, Prev: Ignoring Changes, Up: Shortcomings
4422 18.1.7 Improving Performance
4423 ----------------------------
4425 When comparing two large directory structures, one of which was
4426 originally copied from the other with time stamps preserved (e.g., with
4427 `cp -pR'), it would greatly improve performance if an option told
4428 `diff' to assume that two files with the same size and time stamps have
4429 the same content. *Note diff Performance::.
4432 File: diff.info, Node: Bugs, Prev: Shortcomings, Up: Projects
4437 If you think you have found a bug in GNU `cmp', `diff', `diff3', or
4438 `sdiff', please report it by electronic mail to the GNU utilities bug
4440 (http://mail.gnu.org/mailman/listinfo/bug-gnu-utils)
4441 <bug-gnu-utils@gnu.org>. Please send bug reports for GNU `patch' to
4442 <bug-patch@gnu.org>. Send as precise a description of the problem as
4443 you can, including the output of the `--version' option and sample
4444 input files that produce the bug, if applicable. If you have a
4445 nontrivial fix for the bug, please send it as well. If you have a
4446 patch, please send it too. It may simplify the maintainer's job if the
4447 patch is relative to a recent test release, which you can find in the
4448 directory `ftp://alpha.gnu.org/gnu/diffutils/'.
4451 File: diff.info, Node: Copying This Manual, Next: Translations, Prev: Projects, Up: Top
4453 Appendix A Copying This Manual
4454 ******************************
4458 * GNU Free Documentation License:: License for copying this manual.
4461 File: diff.info, Node: GNU Free Documentation License, Up: Copying This Manual
4463 A.1 GNU Free Documentation License
4464 ==================================
4466 Version 1.2, November 2002
4468 Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
4469 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
4471 Everyone is permitted to copy and distribute verbatim copies
4472 of this license document, but changing it is not allowed.
4476 The purpose of this License is to make a manual, textbook, or other
4477 functional and useful document "free" in the sense of freedom: to
4478 assure everyone the effective freedom to copy and redistribute it,
4479 with or without modifying it, either commercially or
4480 noncommercially. Secondarily, this License preserves for the
4481 author and publisher a way to get credit for their work, while not
4482 being considered responsible for modifications made by others.
4484 This License is a kind of "copyleft", which means that derivative
4485 works of the document must themselves be free in the same sense.
4486 It complements the GNU General Public License, which is a copyleft
4487 license designed for free software.
4489 We have designed this License in order to use it for manuals for
4490 free software, because free software needs free documentation: a
4491 free program should come with manuals providing the same freedoms
4492 that the software does. But this License is not limited to
4493 software manuals; it can be used for any textual work, regardless
4494 of subject matter or whether it is published as a printed book.
4495 We recommend this License principally for works whose purpose is
4496 instruction or reference.
4498 1. APPLICABILITY AND DEFINITIONS
4500 This License applies to any manual or other work, in any medium,
4501 that contains a notice placed by the copyright holder saying it
4502 can be distributed under the terms of this License. Such a notice
4503 grants a world-wide, royalty-free license, unlimited in duration,
4504 to use that work under the conditions stated herein. The
4505 "Document", below, refers to any such manual or work. Any member
4506 of the public is a licensee, and is addressed as "you". You
4507 accept the license if you copy, modify or distribute the work in a
4508 way requiring permission under copyright law.
4510 A "Modified Version" of the Document means any work containing the
4511 Document or a portion of it, either copied verbatim, or with
4512 modifications and/or translated into another language.
4514 A "Secondary Section" is a named appendix or a front-matter section
4515 of the Document that deals exclusively with the relationship of the
4516 publishers or authors of the Document to the Document's overall
4517 subject (or to related matters) and contains nothing that could
4518 fall directly within that overall subject. (Thus, if the Document
4519 is in part a textbook of mathematics, a Secondary Section may not
4520 explain any mathematics.) The relationship could be a matter of
4521 historical connection with the subject or with related matters, or
4522 of legal, commercial, philosophical, ethical or political position
4525 The "Invariant Sections" are certain Secondary Sections whose
4526 titles are designated, as being those of Invariant Sections, in
4527 the notice that says that the Document is released under this
4528 License. If a section does not fit the above definition of
4529 Secondary then it is not allowed to be designated as Invariant.
4530 The Document may contain zero Invariant Sections. If the Document
4531 does not identify any Invariant Sections then there are none.
4533 The "Cover Texts" are certain short passages of text that are
4534 listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4535 that says that the Document is released under this License. A
4536 Front-Cover Text may be at most 5 words, and a Back-Cover Text may
4537 be at most 25 words.
4539 A "Transparent" copy of the Document means a machine-readable copy,
4540 represented in a format whose specification is available to the
4541 general public, that is suitable for revising the document
4542 straightforwardly with generic text editors or (for images
4543 composed of pixels) generic paint programs or (for drawings) some
4544 widely available drawing editor, and that is suitable for input to
4545 text formatters or for automatic translation to a variety of
4546 formats suitable for input to text formatters. A copy made in an
4547 otherwise Transparent file format whose markup, or absence of
4548 markup, has been arranged to thwart or discourage subsequent
4549 modification by readers is not Transparent. An image format is
4550 not Transparent if used for any substantial amount of text. A
4551 copy that is not "Transparent" is called "Opaque".
4553 Examples of suitable formats for Transparent copies include plain
4554 ASCII without markup, Texinfo input format, LaTeX input format,
4555 SGML or XML using a publicly available DTD, and
4556 standard-conforming simple HTML, PostScript or PDF designed for
4557 human modification. Examples of transparent image formats include
4558 PNG, XCF and JPG. Opaque formats include proprietary formats that
4559 can be read and edited only by proprietary word processors, SGML or
4560 XML for which the DTD and/or processing tools are not generally
4561 available, and the machine-generated HTML, PostScript or PDF
4562 produced by some word processors for output purposes only.
4564 The "Title Page" means, for a printed book, the title page itself,
4565 plus such following pages as are needed to hold, legibly, the
4566 material this License requires to appear in the title page. For
4567 works in formats which do not have any title page as such, "Title
4568 Page" means the text near the most prominent appearance of the
4569 work's title, preceding the beginning of the body of the text.
4571 A section "Entitled XYZ" means a named subunit of the Document
4572 whose title either is precisely XYZ or contains XYZ in parentheses
4573 following text that translates XYZ in another language. (Here XYZ
4574 stands for a specific section name mentioned below, such as
4575 "Acknowledgements", "Dedications", "Endorsements", or "History".)
4576 To "Preserve the Title" of such a section when you modify the
4577 Document means that it remains a section "Entitled XYZ" according
4580 The Document may include Warranty Disclaimers next to the notice
4581 which states that this License applies to the Document. These
4582 Warranty Disclaimers are considered to be included by reference in
4583 this License, but only as regards disclaiming warranties: any other
4584 implication that these Warranty Disclaimers may have is void and
4585 has no effect on the meaning of this License.
4589 You may copy and distribute the Document in any medium, either
4590 commercially or noncommercially, provided that this License, the
4591 copyright notices, and the license notice saying this License
4592 applies to the Document are reproduced in all copies, and that you
4593 add no other conditions whatsoever to those of this License. You
4594 may not use technical measures to obstruct or control the reading
4595 or further copying of the copies you make or distribute. However,
4596 you may accept compensation in exchange for copies. If you
4597 distribute a large enough number of copies you must also follow
4598 the conditions in section 3.
4600 You may also lend copies, under the same conditions stated above,
4601 and you may publicly display copies.
4603 3. COPYING IN QUANTITY
4605 If you publish printed copies (or copies in media that commonly
4606 have printed covers) of the Document, numbering more than 100, and
4607 the Document's license notice requires Cover Texts, you must
4608 enclose the copies in covers that carry, clearly and legibly, all
4609 these Cover Texts: Front-Cover Texts on the front cover, and
4610 Back-Cover Texts on the back cover. Both covers must also clearly
4611 and legibly identify you as the publisher of these copies. The
4612 front cover must present the full title with all words of the
4613 title equally prominent and visible. You may add other material
4614 on the covers in addition. Copying with changes limited to the
4615 covers, as long as they preserve the title of the Document and
4616 satisfy these conditions, can be treated as verbatim copying in
4619 If the required texts for either cover are too voluminous to fit
4620 legibly, you should put the first ones listed (as many as fit
4621 reasonably) on the actual cover, and continue the rest onto
4624 If you publish or distribute Opaque copies of the Document
4625 numbering more than 100, you must either include a
4626 machine-readable Transparent copy along with each Opaque copy, or
4627 state in or with each Opaque copy a computer-network location from
4628 which the general network-using public has access to download
4629 using public-standard network protocols a complete Transparent
4630 copy of the Document, free of added material. If you use the
4631 latter option, you must take reasonably prudent steps, when you
4632 begin distribution of Opaque copies in quantity, to ensure that
4633 this Transparent copy will remain thus accessible at the stated
4634 location until at least one year after the last time you
4635 distribute an Opaque copy (directly or through your agents or
4636 retailers) of that edition to the public.
4638 It is requested, but not required, that you contact the authors of
4639 the Document well before redistributing any large number of
4640 copies, to give them a chance to provide you with an updated
4641 version of the Document.
4645 You may copy and distribute a Modified Version of the Document
4646 under the conditions of sections 2 and 3 above, provided that you
4647 release the Modified Version under precisely this License, with
4648 the Modified Version filling the role of the Document, thus
4649 licensing distribution and modification of the Modified Version to
4650 whoever possesses a copy of it. In addition, you must do these
4651 things in the Modified Version:
4653 A. Use in the Title Page (and on the covers, if any) a title
4654 distinct from that of the Document, and from those of
4655 previous versions (which should, if there were any, be listed
4656 in the History section of the Document). You may use the
4657 same title as a previous version if the original publisher of
4658 that version gives permission.
4660 B. List on the Title Page, as authors, one or more persons or
4661 entities responsible for authorship of the modifications in
4662 the Modified Version, together with at least five of the
4663 principal authors of the Document (all of its principal
4664 authors, if it has fewer than five), unless they release you
4665 from this requirement.
4667 C. State on the Title page the name of the publisher of the
4668 Modified Version, as the publisher.
4670 D. Preserve all the copyright notices of the Document.
4672 E. Add an appropriate copyright notice for your modifications
4673 adjacent to the other copyright notices.
4675 F. Include, immediately after the copyright notices, a license
4676 notice giving the public permission to use the Modified
4677 Version under the terms of this License, in the form shown in
4680 G. Preserve in that license notice the full lists of Invariant
4681 Sections and required Cover Texts given in the Document's
4684 H. Include an unaltered copy of this License.
4686 I. Preserve the section Entitled "History", Preserve its Title,
4687 and add to it an item stating at least the title, year, new
4688 authors, and publisher of the Modified Version as given on
4689 the Title Page. If there is no section Entitled "History" in
4690 the Document, create one stating the title, year, authors,
4691 and publisher of the Document as given on its Title Page,
4692 then add an item describing the Modified Version as stated in
4693 the previous sentence.
4695 J. Preserve the network location, if any, given in the Document
4696 for public access to a Transparent copy of the Document, and
4697 likewise the network locations given in the Document for
4698 previous versions it was based on. These may be placed in
4699 the "History" section. You may omit a network location for a
4700 work that was published at least four years before the
4701 Document itself, or if the original publisher of the version
4702 it refers to gives permission.
4704 K. For any section Entitled "Acknowledgements" or "Dedications",
4705 Preserve the Title of the section, and preserve in the
4706 section all the substance and tone of each of the contributor
4707 acknowledgements and/or dedications given therein.
4709 L. Preserve all the Invariant Sections of the Document,
4710 unaltered in their text and in their titles. Section numbers
4711 or the equivalent are not considered part of the section
4714 M. Delete any section Entitled "Endorsements". Such a section
4715 may not be included in the Modified Version.
4717 N. Do not retitle any existing section to be Entitled
4718 "Endorsements" or to conflict in title with any Invariant
4721 O. Preserve any Warranty Disclaimers.
4723 If the Modified Version includes new front-matter sections or
4724 appendices that qualify as Secondary Sections and contain no
4725 material copied from the Document, you may at your option
4726 designate some or all of these sections as invariant. To do this,
4727 add their titles to the list of Invariant Sections in the Modified
4728 Version's license notice. These titles must be distinct from any
4729 other section titles.
4731 You may add a section Entitled "Endorsements", provided it contains
4732 nothing but endorsements of your Modified Version by various
4733 parties--for example, statements of peer review or that the text
4734 has been approved by an organization as the authoritative
4735 definition of a standard.
4737 You may add a passage of up to five words as a Front-Cover Text,
4738 and a passage of up to 25 words as a Back-Cover Text, to the end
4739 of the list of Cover Texts in the Modified Version. Only one
4740 passage of Front-Cover Text and one of Back-Cover Text may be
4741 added by (or through arrangements made by) any one entity. If the
4742 Document already includes a cover text for the same cover,
4743 previously added by you or by arrangement made by the same entity
4744 you are acting on behalf of, you may not add another; but you may
4745 replace the old one, on explicit permission from the previous
4746 publisher that added the old one.
4748 The author(s) and publisher(s) of the Document do not by this
4749 License give permission to use their names for publicity for or to
4750 assert or imply endorsement of any Modified Version.
4752 5. COMBINING DOCUMENTS
4754 You may combine the Document with other documents released under
4755 this License, under the terms defined in section 4 above for
4756 modified versions, provided that you include in the combination
4757 all of the Invariant Sections of all of the original documents,
4758 unmodified, and list them all as Invariant Sections of your
4759 combined work in its license notice, and that you preserve all
4760 their Warranty Disclaimers.
4762 The combined work need only contain one copy of this License, and
4763 multiple identical Invariant Sections may be replaced with a single
4764 copy. If there are multiple Invariant Sections with the same name
4765 but different contents, make the title of each such section unique
4766 by adding at the end of it, in parentheses, the name of the
4767 original author or publisher of that section if known, or else a
4768 unique number. Make the same adjustment to the section titles in
4769 the list of Invariant Sections in the license notice of the
4772 In the combination, you must combine any sections Entitled
4773 "History" in the various original documents, forming one section
4774 Entitled "History"; likewise combine any sections Entitled
4775 "Acknowledgements", and any sections Entitled "Dedications". You
4776 must delete all sections Entitled "Endorsements."
4778 6. COLLECTIONS OF DOCUMENTS
4780 You may make a collection consisting of the Document and other
4781 documents released under this License, and replace the individual
4782 copies of this License in the various documents with a single copy
4783 that is included in the collection, provided that you follow the
4784 rules of this License for verbatim copying of each of the
4785 documents in all other respects.
4787 You may extract a single document from such a collection, and
4788 distribute it individually under this License, provided you insert
4789 a copy of this License into the extracted document, and follow
4790 this License in all other respects regarding verbatim copying of
4793 7. AGGREGATION WITH INDEPENDENT WORKS
4795 A compilation of the Document or its derivatives with other
4796 separate and independent documents or works, in or on a volume of
4797 a storage or distribution medium, is called an "aggregate" if the
4798 copyright resulting from the compilation is not used to limit the
4799 legal rights of the compilation's users beyond what the individual
4800 works permit. When the Document is included in an aggregate, this
4801 License does not apply to the other works in the aggregate which
4802 are not themselves derivative works of the Document.
4804 If the Cover Text requirement of section 3 is applicable to these
4805 copies of the Document, then if the Document is less than one half
4806 of the entire aggregate, the Document's Cover Texts may be placed
4807 on covers that bracket the Document within the aggregate, or the
4808 electronic equivalent of covers if the Document is in electronic
4809 form. Otherwise they must appear on printed covers that bracket
4810 the whole aggregate.
4814 Translation is considered a kind of modification, so you may
4815 distribute translations of the Document under the terms of section
4816 4. Replacing Invariant Sections with translations requires special
4817 permission from their copyright holders, but you may include
4818 translations of some or all Invariant Sections in addition to the
4819 original versions of these Invariant Sections. You may include a
4820 translation of this License, and all the license notices in the
4821 Document, and any Warranty Disclaimers, provided that you also
4822 include the original English version of this License and the
4823 original versions of those notices and disclaimers. In case of a
4824 disagreement between the translation and the original version of
4825 this License or a notice or disclaimer, the original version will
4828 If a section in the Document is Entitled "Acknowledgements",
4829 "Dedications", or "History", the requirement (section 4) to
4830 Preserve its Title (section 1) will typically require changing the
4835 You may not copy, modify, sublicense, or distribute the Document
4836 except as expressly provided for under this License. Any other
4837 attempt to copy, modify, sublicense or distribute the Document is
4838 void, and will automatically terminate your rights under this
4839 License. However, parties who have received copies, or rights,
4840 from you under this License will not have their licenses
4841 terminated so long as such parties remain in full compliance.
4843 10. FUTURE REVISIONS OF THIS LICENSE
4845 The Free Software Foundation may publish new, revised versions of
4846 the GNU Free Documentation License from time to time. Such new
4847 versions will be similar in spirit to the present version, but may
4848 differ in detail to address new problems or concerns. See
4849 `http://www.gnu.org/copyleft/'.
4851 Each version of the License is given a distinguishing version
4852 number. If the Document specifies that a particular numbered
4853 version of this License "or any later version" applies to it, you
4854 have the option of following the terms and conditions either of
4855 that specified version or of any later version that has been
4856 published (not as a draft) by the Free Software Foundation. If
4857 the Document does not specify a version number of this License,
4858 you may choose any version ever published (not as a draft) by the
4859 Free Software Foundation.
4861 A.1.1 ADDENDUM: How to use this License for your documents
4862 ----------------------------------------------------------
4864 To use this License in a document you have written, include a copy of
4865 the License in the document and put the following copyright and license
4866 notices just after the title page:
4868 Copyright (C) YEAR YOUR NAME.
4869 Permission is granted to copy, distribute and/or modify this document
4870 under the terms of the GNU Free Documentation License, Version 1.2
4871 or any later version published by the Free Software Foundation;
4872 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
4873 Texts. A copy of the license is included in the section entitled ``GNU
4874 Free Documentation License''.
4876 If you have Invariant Sections, Front-Cover Texts and Back-Cover
4877 Texts, replace the "with...Texts." line with this:
4879 with the Invariant Sections being LIST THEIR TITLES, with
4880 the Front-Cover Texts being LIST, and with the Back-Cover Texts
4883 If you have Invariant Sections without Cover Texts, or some other
4884 combination of the three, merge those two alternatives to suit the
4887 If your document contains nontrivial examples of program code, we
4888 recommend releasing these examples in parallel under your choice of
4889 free software license, such as the GNU General Public License, to
4890 permit their use in free software.
4893 File: diff.info, Node: Translations, Next: Index, Prev: Copying This Manual, Up: Top
4895 Appendix B Translations of This Manual
4896 **************************************
4898 Nishio Futoshi of the GNUjdoc project has prepared a Japanese
4899 translation of this manual. Its most recent version can be found at
4900 `http://openlab.ring.gr.jp/gnujdoc/cvsweb/cvsweb.cgi/gnujdoc/'.
4903 File: diff.info, Node: Index, Prev: Translations, Up: Top
4911 * ! output format: Context. (line 6)
4912 * +- output format: Unified Format. (line 6)
4913 * < output format: Normal. (line 6)
4914 * <<<<<<< for marking conflicts: Marking Conflicts. (line 6)
4915 * _POSIX2_VERSION: Standards conformance.
4917 * aligning tab stops: Tabs. (line 6)
4918 * alternate file names: Alternate Names. (line 6)
4919 * backup file names: Backup Names. (line 6)
4920 * backup file strategy: Backups. (line 6)
4921 * binary file diff: Binary. (line 6)
4922 * blank and tab difference suppression: White Space. (line 6)
4923 * blank line difference suppression: Blank Lines. (line 6)
4924 * brief difference reports: Brief. (line 6)
4925 * bug reports: Bugs. (line 6)
4926 * C function headings: C Function Headings. (line 6)
4927 * C if-then-else output format: If-then-else. (line 6)
4928 * case difference suppression: Case Folding. (line 6)
4929 * ClearCase: Revision Control. (line 6)
4930 * cmp invocation: Invoking cmp. (line 6)
4931 * cmp options: cmp Options. (line 6)
4932 * columnar output: Side by Side. (line 6)
4933 * common mistakes with patches: Avoiding Common Mistakes.
4935 * comparing three files: Comparing Three Files.
4937 * conflict: diff3 Merging. (line 26)
4938 * conflict marking: Marking Conflicts. (line 6)
4939 * context output format: Context. (line 6)
4940 * creating files: Creating and Removing.
4942 * diagnostics from patch: patch Messages. (line 6)
4943 * diff invocation: Invoking diff. (line 6)
4944 * diff merging: Interactive Merging. (line 6)
4945 * diff options: diff Options. (line 6)
4946 * diff sample input: Sample diff Input. (line 6)
4947 * diff3 hunks: diff3 Hunks. (line 6)
4948 * diff3 invocation: Invoking diff3. (line 6)
4949 * diff3 options: diff3 Options. (line 6)
4950 * diff3 sample input: Sample diff3 Input. (line 6)
4951 * directories and patch: patch Directories. (line 6)
4952 * directory structure changes: Changing Structure. (line 6)
4953 * dry runs for patch: Dry Runs. (line 6)
4954 * ed script output format: ed Scripts. (line 6)
4955 * EDITOR: Merge Commands. (line 46)
4956 * empty files, removing: Creating and Removing.
4958 * exabyte, definition of: cmp Options. (line 105)
4959 * exbibyte, definition of: cmp Options. (line 109)
4960 * FDL, GNU Free Documentation License: GNU Free Documentation License.
4962 * file name alternates: Alternate Names. (line 6)
4963 * file names with unusual characters: Unusual File Names. (line 6)
4964 * format of diff output: Output Formats. (line 6)
4965 * format of diff3 output: Comparing Three Files.
4967 * formats for if-then-else line groups: Line Group Formats. (line 6)
4968 * forward ed script output format: Forward ed. (line 6)
4969 * full lines: Incomplete Lines. (line 6)
4970 * function headings, C: C Function Headings. (line 6)
4971 * fuzz factor when patching: Inexact. (line 6)
4972 * gibibyte, definition of: cmp Options. (line 88)
4973 * gigabyte, definition of: cmp Options. (line 84)
4974 * headings: Sections. (line 6)
4975 * hunks: Hunks. (line 6)
4976 * hunks for diff3: diff3 Hunks. (line 6)
4977 * if-then-else output format: If-then-else. (line 6)
4978 * ifdef output format: If-then-else. (line 6)
4979 * imperfect patch application: Imperfect. (line 6)
4980 * incomplete line merging: Merging Incomplete Lines.
4982 * incomplete lines: Incomplete Lines. (line 6)
4983 * inexact patches: Inexact. (line 6)
4984 * inhibit messages from patch: More or Fewer Messages.
4986 * interactive merging: Interactive Merging. (line 6)
4987 * introduction: Comparison. (line 6)
4988 * intuiting file names from patches: Multiple Patches. (line 6)
4989 * invoking cmp: Invoking cmp. (line 6)
4990 * invoking diff: Invoking diff. (line 6)
4991 * invoking diff3: Invoking diff3. (line 6)
4992 * invoking patch: Invoking patch. (line 6)
4993 * invoking sdiff: Invoking sdiff. (line 6)
4994 * keyboard input to patch: patch and Keyboard Input.
4996 * kibibyte, definition of: cmp Options. (line 72)
4997 * kilobyte, definition of: cmp Options. (line 67)
4998 * LC_COLLATE: Comparing Directories.
5000 * LC_NUMERIC: Line Group Formats. (line 144)
5001 * LC_TIME: Detailed Context. (line 12)
5002 * line formats: Line Formats. (line 6)
5003 * line group formats: Line Group Formats. (line 6)
5004 * mebibyte, definition of: cmp Options. (line 81)
5005 * megabyte, definition of: cmp Options. (line 77)
5006 * merge commands: Merge Commands. (line 6)
5007 * merged diff3 format: Bypassing ed. (line 6)
5008 * merged output format: If-then-else. (line 6)
5009 * merging from a common ancestor: diff3 Merging. (line 6)
5010 * merging interactively: Merge Commands. (line 6)
5011 * messages from patch: patch Messages. (line 6)
5012 * multibyte characters: Internationalization.
5014 * multiple patches: Multiple Patches. (line 6)
5015 * newline treatment by diff: Incomplete Lines. (line 6)
5016 * normal output format: Normal. (line 6)
5017 * options for cmp: cmp Options. (line 6)
5018 * options for diff: diff Options. (line 6)
5019 * options for diff3: diff3 Options. (line 6)
5020 * options for patch: patch Options. (line 6)
5021 * options for sdiff: sdiff Options. (line 6)
5022 * output formats: Output Formats. (line 6)
5023 * overlap: diff3 Merging. (line 26)
5024 * overlapping change, selection of: Which Changes. (line 6)
5025 * overview of diff and patch: Overview. (line 6)
5026 * paginating diff output: Pagination. (line 6)
5027 * patch consumer tips: Tips for Patch Consumers.
5029 * patch input format: patch Input. (line 6)
5030 * patch invocation: Invoking patch. (line 6)
5031 * patch messages and questions: patch Messages. (line 6)
5032 * patch options: patch Options. (line 6)
5033 * patch producer tips: Tips for Patch Producers.
5035 * patch, common mistakes: Avoiding Common Mistakes.
5037 * PATCH_GET: Revision Control. (line 13)
5038 * PATCH_VERSION_CONTROL: Backup Names. (line 21)
5039 * patches, shrinking: Generating Smaller Patches.
5041 * patching directories: patch Directories. (line 6)
5042 * pebibyte, definition of: cmp Options. (line 102)
5043 * performance of diff: diff Performance. (line 6)
5044 * petabyte, definition of: cmp Options. (line 98)
5045 * POSIX <1>: Standards conformance.
5047 * POSIX: patch and POSIX. (line 6)
5048 * POSIXLY_CORRECT <1>: patch and POSIX. (line 6)
5049 * POSIXLY_CORRECT: Standards conformance.
5051 * projects for directories: Shortcomings. (line 6)
5052 * quoting style: patch Quoting Style. (line 6)
5053 * QUOTING_STYLE: patch Quoting Style. (line 30)
5054 * RCS: Revision Control. (line 6)
5055 * RCS script output format: RCS. (line 6)
5056 * regular expression matching headings: Specified Headings. (line 6)
5057 * regular expression suppression: Specified Lines. (line 6)
5058 * reject file names: Reject Names. (line 6)
5059 * removing empty files: Creating and Removing.
5061 * reporting bugs: Bugs. (line 6)
5062 * reversed patches: Reversed Patches. (line 6)
5063 * revision control: Revision Control. (line 6)
5064 * sample input for diff: Sample diff Input. (line 6)
5065 * sample input for diff3: Sample diff3 Input. (line 6)
5066 * SCCS: Revision Control. (line 6)
5067 * script output formats: Scripts. (line 6)
5068 * sdiff invocation: Invoking sdiff. (line 6)
5069 * sdiff options: sdiff Options. (line 6)
5070 * sdiff output format: sdiff Option Summary.
5072 * section headings: Sections. (line 6)
5073 * side by side: Side by Side. (line 6)
5074 * side by side format: Side by Side Format. (line 6)
5075 * SIMPLE_BACKUP_SUFFIX: Backup Names. (line 12)
5076 * special files: Special Files. (line 6)
5077 * specified headings: Specified Headings. (line 6)
5078 * summarizing which files differ: Brief. (line 6)
5079 * System V diff3 compatibility: Saving the Changed File.
5081 * tab and blank difference suppression: White Space. (line 6)
5082 * tab stop alignment: Tabs. (line 6)
5083 * tebibyte, definition of: cmp Options. (line 95)
5084 * terabyte, definition of: cmp Options. (line 91)
5085 * testing patch: Dry Runs. (line 6)
5086 * text versus binary diff: Binary. (line 6)
5087 * time stamp format, context diffs: Detailed Context. (line 12)
5088 * time stamp format, unified diffs: Detailed Unified. (line 12)
5089 * time stamps on patched files: Patching Time Stamps.
5091 * traditional patch: patch and Tradition. (line 6)
5092 * two-column output: Side by Side. (line 6)
5093 * unified output format: Unified Format. (line 6)
5094 * unmerged change: Which Changes. (line 6)
5095 * varying-width characters: Internationalization.
5097 * verbose messages from patch: More or Fewer Messages.
5099 * version control: Revision Control. (line 6)
5100 * VERSION_CONTROL <1>: Revision Control. (line 22)
5101 * VERSION_CONTROL: Backup Names. (line 21)
5102 * white space in patches: Changed White Space. (line 6)
5103 * yottabyte, definition of: cmp Options. (line 120)
5104 * zettabyte, definition of: cmp Options. (line 112)
5110 Node: Overview
\x7f4139
5111 Node: Comparison
\x7f7763
5112 Node: Hunks
\x7f10461
5113 Node: White Space
\x7f11899
5114 Node: Blank Lines
\x7f13354
5115 Node: Specified Lines
\x7f14384
5116 Node: Case Folding
\x7f15506
5117 Node: Brief
\x7f15918
5118 Node: Binary
\x7f17237
5119 Node: Output Formats
\x7f21322
5120 Node: Sample diff Input
\x7f22042
5121 Node: Context
\x7f23536
5122 Node: Context Format
\x7f25108
5123 Node: Example Context
\x7f25895
5124 Node: Less Context
\x7f27397
5125 Node: Detailed Context
\x7f28581
5126 Node: Unified Format
\x7f30774
5127 Node: Example Unified
\x7f31565
5128 Node: Detailed Unified
\x7f32598
5129 Node: Sections
\x7f34240
5130 Node: Specified Headings
\x7f34994
5131 Node: C Function Headings
\x7f36543
5132 Node: Alternate Names
\x7f37385
5133 Node: Side by Side
\x7f38294
5134 Node: Side by Side Format
\x7f40438
5135 Node: Example Side by Side
\x7f41336
5136 Node: Normal
\x7f42671
5137 Node: Example Normal
\x7f43666
5138 Node: Detailed Normal
\x7f44397
5139 Node: Scripts
\x7f46131
5140 Node: ed Scripts
\x7f46531
5141 Node: Example ed
\x7f47733
5142 Node: Detailed ed
\x7f48178
5143 Node: Forward ed
\x7f49932
5145 Node: If-then-else
\x7f51915
5146 Node: Line Group Formats
\x7f53588
5147 Node: Line Formats
\x7f59459
5148 Node: Example If-then-else
\x7f62724
5149 Node: Detailed If-then-else
\x7f63798
5150 Node: Incomplete Lines
\x7f65676
5151 Node: Comparing Directories
\x7f67308
5152 Node: Adjusting Output
\x7f71352
5154 Node: Pagination
\x7f73383
5155 Node: diff Performance
\x7f73836
5156 Node: Comparing Three Files
\x7f76919
5157 Node: Sample diff3 Input
\x7f77792
5158 Node: Example diff3 Normal
\x7f78735
5159 Node: Detailed diff3 Normal
\x7f79780
5160 Node: diff3 Hunks
\x7f81537
5161 Node: diff3 Merging
\x7f82828
5162 Node: Which Changes
\x7f85067
5163 Node: Marking Conflicts
\x7f86466
5164 Node: Bypassing ed
\x7f88920
5165 Node: Merging Incomplete Lines
\x7f90259
5166 Node: Saving the Changed File
\x7f90980
5167 Node: Interactive Merging
\x7f91591
5168 Node: sdiff Option Summary
\x7f92296
5169 Node: Merge Commands
\x7f93467
5170 Node: Merging with patch
\x7f94733
5171 Node: patch Input
\x7f97100
5172 Node: Revision Control
\x7f97777
5173 Node: Imperfect
\x7f98943
5174 Node: Changed White Space
\x7f100086
5175 Node: Reversed Patches
\x7f100878
5176 Node: Inexact
\x7f102338
5177 Node: Dry Runs
\x7f105892
5178 Node: Creating and Removing
\x7f106751
5179 Node: Patching Time Stamps
\x7f107797
5180 Node: Multiple Patches
\x7f109995
5181 Node: patch Directories
\x7f112653
5182 Node: Backups
\x7f114274
5183 Node: Backup Names
\x7f115335
5184 Ref: Backup Names-Footnote-1
\x7f118299
5185 Node: Reject Names
\x7f118426
5186 Node: patch Messages
\x7f119010
5187 Node: More or Fewer Messages
\x7f120065
5188 Node: patch and Keyboard Input
\x7f120691
5189 Node: patch Quoting Style
\x7f121717
5190 Node: patch and POSIX
\x7f122862
5191 Node: patch and Tradition
\x7f123697
5192 Node: Making Patches
\x7f127149
5193 Node: Tips for Patch Producers
\x7f127970
5194 Node: Tips for Patch Consumers
\x7f129221
5195 Node: Avoiding Common Mistakes
\x7f129853
5196 Node: Generating Smaller Patches
\x7f132373
5197 Node: Invoking cmp
\x7f134129
5198 Node: cmp Options
\x7f135547
5199 Node: Invoking diff
\x7f138960
5200 Node: diff Options
\x7f140813
5201 Node: Invoking diff3
\x7f149059
5202 Node: diff3 Options
\x7f149692
5203 Node: Invoking patch
\x7f152720
5204 Node: patch Options
\x7f153923
5205 Node: Invoking sdiff
\x7f159145
5206 Node: sdiff Options
\x7f160287
5207 Node: Standards conformance
\x7f163162
5208 Node: Projects
\x7f164903
5209 Node: Shortcomings
\x7f165609
5210 Node: Internationalization
\x7f166706
5211 Node: Changing Structure
\x7f167867
5212 Node: Special Files
\x7f168966
5213 Node: Unusual File Names
\x7f170073
5214 Node: Time Stamp Order
\x7f170707
5215 Node: Ignoring Changes
\x7f171345
5216 Node: Speedups
\x7f172110
5217 Node: Bugs
\x7f172569
5218 Node: Copying This Manual
\x7f173417
5219 Node: GNU Free Documentation License
\x7f173654
5220 Node: Translations
\x7f196061
5221 Node: Index
\x7f196428