Imported Upstream version 3.8
[platform/upstream/diffutils.git] / doc / diffutils.info
1 This is diffutils.info, produced by makeinfo version 6.8 from
2 diffutils.texi.
3
4 This manual is for GNU Diffutils (version 3.8, 2 January 2021), and
5 documents the GNU 'diff', 'diff3', 'sdiff', and 'cmp' commands for
6 showing the differences between files and the GNU 'patch' command for
7 using their output to update files.
8
9    Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2021 Free
10 Software Foundation, Inc.
11
12      Permission is granted to copy, distribute and/or modify this
13      document under the terms of the GNU Free Documentation License,
14      Version 1.3 or any later version published by the Free Software
15      Foundation; with no Invariant Sections, no Front-Cover Texts, and
16      no Back-Cover Texts.  A copy of the license is included in the
17      section entitled "GNU Free Documentation License."
18 INFO-DIR-SECTION Individual utilities
19 START-INFO-DIR-ENTRY
20 * cmp: (diffutils)Invoking cmp.                 Compare 2 files byte by byte.
21 * diff: (diffutils)Invoking diff.               Compare 2 files line by line.
22 * diff3: (diffutils)Invoking diff3.             Compare 3 files line by line.
23 * patch: (diffutils)Invoking patch.             Apply a patch to a file.
24 * sdiff: (diffutils)Invoking sdiff.             Merge 2 files side-by-side.
25 END-INFO-DIR-ENTRY
26
27 INFO-DIR-SECTION Text creation and manipulation
28 START-INFO-DIR-ENTRY
29 * Diffutils: (diffutils).       Comparing and merging files.
30 END-INFO-DIR-ENTRY
31
32 \1f
33 File: diffutils.info,  Node: Top,  Next: Overview,  Up: (dir)
34
35 Comparing and Merging Files
36 ***************************
37
38 This manual is for GNU Diffutils (version 3.8, 2 January 2021), and
39 documents the GNU 'diff', 'diff3', 'sdiff', and 'cmp' commands for
40 showing the differences between files and the GNU 'patch' command for
41 using their output to update files.
42
43    Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2021 Free
44 Software Foundation, Inc.
45
46      Permission is granted to copy, distribute and/or modify this
47      document under the terms of the GNU Free Documentation License,
48      Version 1.3 or any later version published by the Free Software
49      Foundation; with no Invariant Sections, no Front-Cover Texts, and
50      no Back-Cover Texts.  A copy of the license is included in the
51      section entitled "GNU Free Documentation License."
52
53 * Menu:
54
55 * Overview::              Preliminary information.
56 * Comparison::            What file comparison means.
57
58 * Output Formats::        Formats for two-way difference reports.
59 * Incomplete Lines::      Lines that lack trailing newlines.
60 * Comparing Directories:: Comparing files and directories.
61 * Adjusting Output::      Making 'diff' output prettier.
62 * diff Performance::      Making 'diff' smarter or faster.
63
64 * Comparing Three Files:: Formats for three-way difference reports.
65 * diff3 Merging::         Merging from a common ancestor.
66
67 * Interactive Merging::   Interactive merging with 'sdiff'.
68
69 * Merging with patch::    Using 'patch' to change old files into new ones.
70 * Making Patches::        Tips for making and using patch distributions.
71
72 * Invoking cmp::          Compare two files byte by byte.
73 * Invoking diff::         Compare two files line by line.
74 * Invoking diff3::        Compare three files line by line.
75 * Invoking patch::        Apply a diff file to an original.
76 * Invoking sdiff::        Side-by-side merge of file differences.
77
78 * Standards conformance:: Conformance to the POSIX standard.
79 * Projects::              If you've found a bug or other shortcoming.
80
81 * Copying This Manual::   How to make copies of this manual.
82 * Translations::          Available translations of this manual.
83 * Index::                 Index.
84
85 \1f
86 File: diffutils.info,  Node: Overview,  Next: Comparison,  Prev: Top,  Up: Top
87
88 Overview
89 ********
90
91 Computer users often find occasion to ask how two files differ.  Perhaps
92 one file is a newer version of the other file.  Or maybe the two files
93 started out as identical copies but were changed by different people.
94
95    You can use the 'diff' command to show differences between two files,
96 or each corresponding file in two directories.  'diff' outputs
97 differences between files line by line in any of several formats,
98 selectable by command line options.  This set of differences is often
99 called a "diff" or "patch".  For files that are identical, 'diff'
100 normally produces no output; for binary (non-text) files, 'diff'
101 normally reports only that they are different.
102
103    You can use the 'cmp' command to show the byte and line numbers where
104 two files differ.  'cmp' can also show all the bytes that differ between
105 the two files, side by side.  A way to compare two files character by
106 character is the Emacs command 'M-x compare-windows'.  *Note Other
107 Window: (emacs)Other Window, for more information on that command.
108
109    You can use the 'diff3' command to show differences among three
110 files.  When two people have made independent changes to a common
111 original, 'diff3' can report the differences between the original and
112 the two changed versions, and can produce a merged file that contains
113 both persons' changes together with warnings about conflicts.
114
115    You can use the 'sdiff' command to merge two files interactively.
116
117    You can use the set of differences produced by 'diff' to distribute
118 updates to text files (such as program source code) to other people.
119 This method is especially useful when the differences are small compared
120 to the complete files.  Given 'diff' output, you can use the 'patch'
121 program to update, or "patch", a copy of the file.  If you think of
122 'diff' as subtracting one file from another to produce their difference,
123 you can think of 'patch' as adding the difference to one file to
124 reproduce the other.
125
126    This manual first concentrates on making diffs, and later shows how
127 to use diffs to update files.
128
129    GNU 'diff' was written by Paul Eggert, Mike Haertel, David Hayes,
130 Richard Stallman, and Len Tower.  Wayne Davison designed and implemented
131 the unified output format.  The basic algorithm is described by Eugene
132 W. Myers in "An O(ND) Difference Algorithm and its Variations",
133 'Algorithmica' Vol. 1, 1986, pp. 251-266,
134 <http://dx.doi.org/10.1007/BF01840446>; and in "A File Comparison
135 Program", Webb Miller and Eugene W. Myers, 'Software--Practice and
136 Experience' Vol. 15, 1985, pp. 1025-1040,
137 <http://dx.doi.org/10.1002/spe.4380151102>.  The algorithm was
138 independently discovered as described by Esko Ukkonen in "Algorithms for
139 Approximate String Matching", 'Information and Control' Vol. 64, 1985,
140 pp. 100-118, <http://dx.doi.org/10.1016/S0019-9958(85)80046-2>.  Unless
141 the '--minimal' option is used, 'diff' uses a heuristic by Paul Eggert
142 that limits the cost to O(N^1.5 log N) at the price of producing
143 suboptimal output for large inputs with many differences.  Related
144 algorithms are surveyed by Alfred V. Aho in section 6.3 of "Algorithms
145 for Finding Patterns in Strings", 'Handbook of Theoretical Computer
146 Science' (Jan Van Leeuwen, ed.), Vol. A, 'Algorithms and Complexity',
147 Elsevier/MIT Press, 1990, pp. 255-300.
148
149    GNU 'diff3' was written by Randy Smith.  GNU 'sdiff' was written by
150 Thomas Lord.  GNU 'cmp' was written by Torbjörn Granlund and David
151 MacKenzie.
152
153    GNU 'patch' was written mainly by Larry Wall and Paul Eggert; several
154 GNU enhancements were contributed by Wayne Davison and David MacKenzie.
155 Parts of this manual are adapted from a manual page written by Larry
156 Wall, with his permission.
157
158 \1f
159 File: diffutils.info,  Node: Comparison,  Next: Output Formats,  Prev: Overview,  Up: Top
160
161 1 What Comparison Means
162 ***********************
163
164 There are several ways to think about the differences between two files.
165 One way to think of the differences is as a series of lines that were
166 deleted from, inserted in, or changed in one file to produce the other
167 file.  'diff' compares two files line by line, finds groups of lines
168 that differ, and reports each group of differing lines.  It can report
169 the differing lines in several formats, which have different purposes.
170
171    GNU 'diff' can show whether files are different without detailing the
172 differences.  It also provides ways to suppress certain kinds of
173 differences that are not important to you.  Most commonly, such
174 differences are changes in the amount of white space between words or
175 lines.  'diff' also provides ways to suppress differences in alphabetic
176 case or in lines that match a regular expression that you provide.
177 These options can accumulate; for example, you can ignore changes in
178 both white space and alphabetic case.
179
180    Another way to think of the differences between two files is as a
181 sequence of pairs of bytes that can be either identical or different.
182 'cmp' reports the differences between two files byte by byte, instead of
183 line by line.  As a result, it is often more useful than 'diff' for
184 comparing binary files.  For text files, 'cmp' is useful mainly when you
185 want to know only whether two files are identical, or whether one file
186 is a prefix of the other.
187
188    To illustrate the effect that considering changes byte by byte can
189 have compared with considering them line by line, think of what happens
190 if a single newline character is added to the beginning of a file.  If
191 that file is then compared with an otherwise identical file that lacks
192 the newline at the beginning, 'diff' will report that a blank line has
193 been added to the file, while 'cmp' will report that almost every byte
194 of the two files differs.
195
196    'diff3' normally compares three input files line by line, finds
197 groups of lines that differ, and reports each group of differing lines.
198 Its output is designed to make it easy to inspect two different sets of
199 changes to the same file.
200
201    These commands compare input files without necessarily reading them.
202 For example, if 'diff' is asked simply to report whether two files
203 differ, and it discovers that the files have different sizes, it need
204 not read them to do its job.
205
206 * Menu:
207
208 * Hunks::             Groups of differing lines.
209 * White Space::       Suppressing differences in white space.
210 * Blank Lines::       Suppressing differences whose lines are all blank.
211 * Specified Lines::   Suppressing differences whose lines all match a pattern.
212 * Case Folding::      Suppressing differences in alphabetic case.
213 * Brief::             Summarizing which files are different.
214 * Binary::            Comparing binary files or forcing text comparisons.
215
216 \1f
217 File: diffutils.info,  Node: Hunks,  Next: White Space,  Up: Comparison
218
219 1.1 Hunks
220 =========
221
222 When comparing two files, 'diff' finds sequences of lines common to both
223 files, interspersed with groups of differing lines called "hunks".
224 Comparing two identical files yields one sequence of common lines and no
225 hunks, because no lines differ.  Comparing two entirely different files
226 yields no common lines and one large hunk that contains all lines of
227 both files.  In general, there are many ways to match up lines between
228 two given files.  'diff' tries to minimize the total hunk size by
229 finding large sequences of common lines interspersed with small hunks of
230 differing lines.
231
232    For example, suppose the file 'F' contains the three lines 'a', 'b',
233 'c', and the file 'G' contains the same three lines in reverse order
234 'c', 'b', 'a'.  If 'diff' finds the line 'c' as common, then the command
235 'diff F G' produces this output:
236
237      1,2d0
238      < a
239      < b
240      3a2,3
241      > b
242      > a
243
244 But if 'diff' notices the common line 'b' instead, it produces this
245 output:
246
247      1c1
248      < a
249      ---
250      > c
251      3c3
252      < c
253      ---
254      > a
255
256 It is also possible to find 'a' as the common line.  'diff' does not
257 always find an optimal matching between the files; it takes shortcuts to
258 run faster.  But its output is usually close to the shortest possible.
259 You can adjust this tradeoff with the '--minimal' ('-d') option (*note
260 diff Performance::).
261
262 \1f
263 File: diffutils.info,  Node: White Space,  Next: Blank Lines,  Prev: Hunks,  Up: Comparison
264
265 1.2 Suppressing Differences in Blank and Tab Spacing
266 ====================================================
267
268 The '--ignore-tab-expansion' ('-E') option ignores the distinction
269 between tabs and spaces on input.  A tab is considered to be equivalent
270 to the number of spaces to the next tab stop (*note Tabs::).
271
272    The '--ignore-trailing-space' ('-Z') option ignores white space at
273 line end.
274
275    The '--ignore-space-change' ('-b') option is stronger than '-E' and
276 '-Z' combined.  It ignores white space at line end, and considers all
277 other sequences of one or more white space characters within a line to
278 be equivalent.  With this option, 'diff' considers the following two
279 lines to be equivalent, where '$' denotes the line end:
280
281      Here lyeth  muche rychnesse  in lytell space.   -- John Heywood$
282      Here lyeth muche rychnesse in lytell space. -- John Heywood   $
283
284    The '--ignore-all-space' ('-w') option is stronger still.  It ignores
285 differences even if one line has white space where the other line has
286 none.  "White space" characters include tab, vertical tab, form feed,
287 carriage return, and space; some locales may define additional
288 characters to be white space.  With this option, 'diff' considers the
289 following two lines to be equivalent, where '$' denotes the line end and
290 '^M' denotes a carriage return:
291
292      Here lyeth  muche  rychnesse in lytell space.--  John Heywood$
293        He relyeth much erychnes  seinly tells pace.  --John Heywood   ^M$
294
295    For many other programs newline is also a white space character, but
296 'diff' is a line-oriented program and a newline character always ends a
297 line.  Hence the '-w' or '--ignore-all-space' option does not ignore
298 newline-related changes; it ignores only other white space changes.
299
300 \1f
301 File: diffutils.info,  Node: Blank Lines,  Next: Specified Lines,  Prev: White Space,  Up: Comparison
302
303 1.3 Suppressing Differences Whose Lines Are All Blank
304 =====================================================
305
306 The '--ignore-blank-lines' ('-B') option ignores changes that consist
307 entirely of blank lines.  With this option, for example, a file
308 containing
309      1.  A point is that which has no part.
310
311      2.  A line is breadthless length.
312      -- Euclid, The Elements, I
313 is considered identical to a file containing
314      1.  A point is that which has no part.
315      2.  A line is breadthless length.
316
317
318      -- Euclid, The Elements, I
319
320    Normally this option affects only lines that are completely empty,
321 but if you also specify an option that ignores trailing spaces, lines
322 are also affected if they look empty but contain white space.  In other
323 words, '-B' is equivalent to '-I '^$'' by default, but it is equivalent
324 to '-I '^[[:space:]]*$'' if '-b', '-w' or '-Z' is also specified.
325
326 \1f
327 File: diffutils.info,  Node: Specified Lines,  Next: Case Folding,  Prev: Blank Lines,  Up: Comparison
328
329 1.4 Suppressing Differences Whose Lines All Match a Regular Expression
330 ======================================================================
331
332 To ignore insertions and deletions of lines that match a 'grep'-style
333 regular expression, use the '--ignore-matching-lines=REGEXP' ('-I
334 REGEXP') option.  You should escape regular expressions that contain
335 shell metacharacters to prevent the shell from expanding them.  For
336 example, 'diff -I '^[[:digit:]]'' ignores all changes to lines beginning
337 with a digit.
338
339    However, '-I' only ignores the insertion or deletion of lines that
340 contain the regular expression if every changed line in the hunk--every
341 insertion and every deletion--matches the regular expression.  In other
342 words, for each nonignorable change, 'diff' prints the complete set of
343 changes in its vicinity, including the ignorable ones.
344
345    You can specify more than one regular expression for lines to ignore
346 by using more than one '-I' option.  'diff' tries to match each line
347 against each regular expression.
348
349 \1f
350 File: diffutils.info,  Node: Case Folding,  Next: Brief,  Prev: Specified Lines,  Up: Comparison
351
352 1.5 Suppressing Case Differences
353 ================================
354
355 GNU 'diff' can treat lower case letters as equivalent to their upper
356 case counterparts, so that, for example, it considers 'Funky Stuff',
357 'funky STUFF', and 'fUNKy stuFf' to all be the same.  To request this,
358 use the '-i' or '--ignore-case' option.
359
360 \1f
361 File: diffutils.info,  Node: Brief,  Next: Binary,  Prev: Case Folding,  Up: Comparison
362
363 1.6 Summarizing Which Files Differ
364 ==================================
365
366 When you only want to find out whether files are different, and you
367 don't care what the differences are, you can use the summary output
368 format.  In this format, instead of showing the differences between the
369 files, 'diff' simply reports whether files differ.  The '--brief' ('-q')
370 option selects this output format.
371
372    This format is especially useful when comparing the contents of two
373 directories.  It is also much faster than doing the normal line by line
374 comparisons, because 'diff' can stop analyzing the files as soon as it
375 knows that there are any differences.
376
377    You can also get a brief indication of whether two files differ by
378 using 'cmp'.  For files that are identical, 'cmp' produces no output.
379 When the files differ, by default, 'cmp' outputs the byte and line
380 number where the first difference occurs, or reports that one file is a
381 prefix of the other.  You can use the '-s', '--quiet', or '--silent'
382 option to suppress that information, so that 'cmp' produces no output
383 and reports whether the files differ using only its exit status (*note
384 Invoking cmp::).
385
386    Unlike 'diff', 'cmp' cannot compare directories; it can only compare
387 two files.
388
389 \1f
390 File: diffutils.info,  Node: Binary,  Prev: Brief,  Up: Comparison
391
392 1.7 Binary Files and Forcing Text Comparisons
393 =============================================
394
395 If 'diff' thinks that either of the two files it is comparing is binary
396 (a non-text file), it normally treats that pair of files much as if the
397 summary output format had been selected (*note Brief::), and reports
398 only that the binary files are different.  This is because line by line
399 comparisons are usually not meaningful for binary files.  This does not
400 count as trouble, even though the resulting output does not capture all
401 the differences.
402
403    'diff' determines whether a file is text or binary by checking the
404 first few bytes in the file; the exact number of bytes is system
405 dependent, but it is typically several thousand.  If every byte in that
406 part of the file is non-null, 'diff' considers the file to be text;
407 otherwise it considers the file to be binary.
408
409    Sometimes you might want to force 'diff' to consider files to be
410 text.  For example, you might be comparing text files that contain null
411 characters; 'diff' would erroneously decide that those are non-text
412 files.  Or you might be comparing documents that are in a format used by
413 a word processing system that uses null characters to indicate special
414 formatting.  You can force 'diff' to consider all files to be text
415 files, and compare them line by line, by using the '--text' ('-a')
416 option.  If the files you compare using this option do not in fact
417 contain text, they will probably contain few newline characters, and the
418 'diff' output will consist of hunks showing differences between long
419 lines of whatever characters the files contain.
420
421    You can also force 'diff' to report only whether files differ (but
422 not how).  Use the '--brief' ('-q') option for this.
423
424    In operating systems that distinguish between text and binary files,
425 'diff' normally reads and writes all data as text.  Use the '--binary'
426 option to force 'diff' to read and write binary data instead.  This
427 option has no effect on a POSIX-compliant system like GNU or traditional
428 Unix.  However, many personal computer operating systems represent the
429 end of a line with a carriage return followed by a newline.  On such
430 systems, 'diff' normally ignores these carriage returns on input and
431 generates them at the end of each output line, but with the '--binary'
432 option 'diff' treats each carriage return as just another input
433 character, and does not generate a carriage return at the end of each
434 output line.  This can be useful when dealing with non-text files that
435 are meant to be interchanged with POSIX-compliant systems.
436
437    The '--strip-trailing-cr' causes 'diff' to treat input lines that end
438 in carriage return followed by newline as if they end in plain newline.
439 This can be useful when comparing text that is imperfectly imported from
440 many personal computer operating systems.  This option affects how lines
441 are read, which in turn affects how they are compared and output.
442
443    If you want to compare two files byte by byte, you can use the 'cmp'
444 program with the '--verbose' ('-l') option to show the values of each
445 differing byte in the two files.  With GNU 'cmp', you can also use the
446 '-b' or '--print-bytes' option to show the ASCII representation of those
447 bytes.  *Note Invoking cmp::, for more information.
448
449    If 'diff3' thinks that any of the files it is comparing is binary (a
450 non-text file), it normally reports an error, because such comparisons
451 are usually not useful.  'diff3' uses the same test as 'diff' to decide
452 whether a file is binary.  As with 'diff', if the input files contain a
453 few non-text bytes but otherwise are like text files, you can force
454 'diff3' to consider all files to be text files and compare them line by
455 line by using the '-a' or '--text' option.
456
457 \1f
458 File: diffutils.info,  Node: Output Formats,  Next: Incomplete Lines,  Prev: Comparison,  Up: Top
459
460 2 'diff' Output Formats
461 ***********************
462
463 'diff' has several mutually exclusive options for output format.  The
464 following sections describe each format, illustrating how 'diff' reports
465 the differences between two sample input files.
466
467 * Menu:
468
469 * Sample diff Input:: Sample 'diff' input files for examples.
470 * Context::           Showing differences with the surrounding text.
471 * Side by Side::      Showing differences in two columns.
472 * Normal::            Showing differences without surrounding text.
473 * Scripts::           Generating scripts for other programs.
474 * If-then-else::      Merging files with if-then-else.
475
476 \1f
477 File: diffutils.info,  Node: Sample diff Input,  Next: Context,  Up: Output Formats
478
479 2.1 Two Sample Input Files
480 ==========================
481
482 Here are two sample files that we will use in numerous examples to
483 illustrate the output of 'diff' and how various options can change it.
484
485    This is the file 'lao':
486
487      The Way that can be told of is not the eternal Way;
488      The name that can be named is not the eternal name.
489      The Nameless is the origin of Heaven and Earth;
490      The Named is the mother of all things.
491      Therefore let there always be non-being,
492        so we may see their subtlety,
493      And let there always be being,
494        so we may see their outcome.
495      The two are the same,
496      But after they are produced,
497        they have different names.
498
499    This is the file 'tzu':
500
501      The Nameless is the origin of Heaven and Earth;
502      The named is the mother of all things.
503
504      Therefore let there always be non-being,
505        so we may see their subtlety,
506      And let there always be being,
507        so we may see their outcome.
508      The two are the same,
509      But after they are produced,
510        they have different names.
511      They both may be called deep and profound.
512      Deeper and more profound,
513      The door of all subtleties!
514
515    In this example, the first hunk contains just the first two lines of
516 'lao', the second hunk contains the fourth line of 'lao' opposing the
517 second and third lines of 'tzu', and the last hunk contains just the
518 last three lines of 'tzu'.
519
520 \1f
521 File: diffutils.info,  Node: Context,  Next: Side by Side,  Prev: Sample diff Input,  Up: Output Formats
522
523 2.2 Showing Differences in Their Context
524 ========================================
525
526 Usually, when you are looking at the differences between files, you will
527 also want to see the parts of the files near the lines that differ, to
528 help you understand exactly what has changed.  These nearby parts of the
529 files are called the "context".
530
531    GNU 'diff' provides two output formats that show context around the
532 differing lines: "context format" and "unified format".  It can
533 optionally show in which function or section of the file the differing
534 lines are found.
535
536    If you are distributing new versions of files to other people in the
537 form of 'diff' output, you should use one of the output formats that
538 show context so that they can apply the diffs even if they have made
539 small changes of their own to the files.  'patch' can apply the diffs in
540 this case by searching in the files for the lines of context around the
541 differing lines; if those lines are actually a few lines away from where
542 the diff says they are, 'patch' can adjust the line numbers accordingly
543 and still apply the diff correctly.  *Note Imperfect::, for more
544 information on using 'patch' to apply imperfect diffs.
545
546 * Menu:
547
548 * Context Format::  An output format that shows surrounding lines.
549 * Unified Format::  A more compact output format that shows context.
550 * Sections::        Showing which sections of the files differences are in.
551 * Alternate Names:: Showing alternate file names in context headers.
552
553 \1f
554 File: diffutils.info,  Node: Context Format,  Next: Unified Format,  Up: Context
555
556 2.2.1 Context Format
557 --------------------
558
559 The context output format shows several lines of context around the
560 lines that differ.  It is the standard format for distributing updates
561 to source code.
562
563    To select this output format, use the '--context[=LINES]' ('-C
564 LINES') or '-c' option.  The argument LINES that some of these options
565 take is the number of lines of context to show.  If you do not specify
566 LINES, it defaults to three.  For proper operation, 'patch' typically
567 needs at least two lines of context.
568
569 * Menu:
570
571 * Example Context::  Sample output in context format.
572 * Less Context::     Another sample with less context.
573 * Detailed Context:: A detailed description of the context output format.
574
575 \1f
576 File: diffutils.info,  Node: Example Context,  Next: Less Context,  Up: Context Format
577
578 2.2.1.1 An Example of Context Format
579 ....................................
580
581 Here is the output of 'diff -c lao tzu' (*note Sample diff Input::, for
582 the complete contents of the two files).  Notice that up to three lines
583 that are not different are shown around each line that is different;
584 they are the context lines.  Also notice that the first two hunks have
585 run together, because their contents overlap.
586
587      *** lao    2002-02-21 23:30:39.942229878 -0800
588      --- tzu    2002-02-21 23:30:50.442260588 -0800
589      ***************
590      *** 1,7 ****
591      - The Way that can be told of is not the eternal Way;
592      - The name that can be named is not the eternal name.
593        The Nameless is the origin of Heaven and Earth;
594      ! The Named is the mother of all things.
595        Therefore let there always be non-being,
596          so we may see their subtlety,
597        And let there always be being,
598      --- 1,6 ----
599        The Nameless is the origin of Heaven and Earth;
600      ! The named is the mother of all things.
601      !
602        Therefore let there always be non-being,
603          so we may see their subtlety,
604        And let there always be being,
605      ***************
606      *** 9,11 ****
607      --- 8,13 ----
608        The two are the same,
609        But after they are produced,
610          they have different names.
611      + They both may be called deep and profound.
612      + Deeper and more profound,
613      + The door of all subtleties!
614
615 \1f
616 File: diffutils.info,  Node: Less Context,  Next: Detailed Context,  Prev: Example Context,  Up: Context Format
617
618 2.2.1.2 An Example of Context Format with Less Context
619 ......................................................
620
621 Here is the output of 'diff -C 1 lao tzu' (*note Sample diff Input::,
622 for the complete contents of the two files).  Notice that at most one
623 context line is reported here.
624
625      *** lao    2002-02-21 23:30:39.942229878 -0800
626      --- tzu    2002-02-21 23:30:50.442260588 -0800
627      ***************
628      *** 1,5 ****
629      - The Way that can be told of is not the eternal Way;
630      - The name that can be named is not the eternal name.
631        The Nameless is the origin of Heaven and Earth;
632      ! The Named is the mother of all things.
633        Therefore let there always be non-being,
634      --- 1,4 ----
635        The Nameless is the origin of Heaven and Earth;
636      ! The named is the mother of all things.
637      !
638        Therefore let there always be non-being,
639      ***************
640      *** 11 ****
641      --- 10,13 ----
642          they have different names.
643      + They both may be called deep and profound.
644      + Deeper and more profound,
645      + The door of all subtleties!
646
647 \1f
648 File: diffutils.info,  Node: Detailed Context,  Prev: Less Context,  Up: Context Format
649
650 2.2.1.3 Detailed Description of Context Format
651 ..............................................
652
653 The context output format starts with a two-line header, which looks
654 like this:
655
656      *** FROM-FILE FROM-FILE-MODIFICATION-TIME
657      --- TO-FILE TO-FILE-MODIFICATION TIME
658
659 The timestamp normally looks like '2002-02-21 23:30:39.942229878 -0800'
660 to indicate the date, time with fractional seconds, and time zone in
661 Internet RFC 2822 format (ftp://ftp.isi.edu/in-notes/rfc2822.txt).  (The
662 fractional seconds are omitted on hosts that do not support fractional
663 timestamps.)  However, a traditional timestamp like 'Thu Feb 21 23:30:39
664 2002' is used if the 'LC_TIME' locale category is either 'C' or 'POSIX'.
665
666    You can change the header's content with the '--label=LABEL' option;
667 see *note Alternate Names::.
668
669    Next come one or more hunks of differences; each hunk shows one area
670 where the files differ.  Context format hunks look like this:
671
672      ***************
673      *** FROM-FILE-LINE-NUMBERS ****
674        FROM-FILE-LINE
675        FROM-FILE-LINE...
676      --- TO-FILE-LINE-NUMBERS ----
677        TO-FILE-LINE
678        TO-FILE-LINE...
679
680    If a hunk contains two or more lines, its line numbers look like
681 'START,END'.  Otherwise only its end line number appears.  An empty hunk
682 is considered to end at the line that precedes the hunk.
683
684    The lines of context around the lines that differ start with two
685 space characters.  The lines that differ between the two files start
686 with one of the following indicator characters, followed by a space
687 character:
688
689 '!'
690      A line that is part of a group of one or more lines that changed
691      between the two files.  There is a corresponding group of lines
692      marked with '!' in the part of this hunk for the other file.
693
694 '+'
695      An "inserted" line in the second file that corresponds to nothing
696      in the first file.
697
698 '-'
699      A "deleted" line in the first file that corresponds to nothing in
700      the second file.
701
702    If all of the changes in a hunk are insertions, the lines of
703 FROM-FILE are omitted.  If all of the changes are deletions, the lines
704 of TO-FILE are omitted.
705
706 \1f
707 File: diffutils.info,  Node: Unified Format,  Next: Sections,  Prev: Context Format,  Up: Context
708
709 2.2.2 Unified Format
710 --------------------
711
712 The unified output format is a variation on the context format that is
713 more compact because it omits redundant context lines.  To select this
714 output format, use the '--unified[=LINES]' ('-U LINES'), or '-u' option.
715 The argument LINES is the number of lines of context to show.  When it
716 is not given, it defaults to three.
717
718    In the early 1990s, only GNU 'diff' could produce this format and
719 only GNU 'patch' could automatically apply diffs in this format.  For
720 proper operation, 'patch' typically needs at least three lines of
721 context.
722
723 * Menu:
724
725 * Example Unified::  Sample output in unified format.
726 * Detailed Unified:: A detailed description of unified format.
727
728 \1f
729 File: diffutils.info,  Node: Example Unified,  Next: Detailed Unified,  Up: Unified Format
730
731 2.2.2.1 An Example of Unified Format
732 ....................................
733
734 Here is the output of the command 'diff -u lao tzu' (*note Sample diff
735 Input::, for the complete contents of the two files):
736
737      --- lao    2002-02-21 23:30:39.942229878 -0800
738      +++ tzu    2002-02-21 23:30:50.442260588 -0800
739      @@ -1,7 +1,6 @@
740      -The Way that can be told of is not the eternal Way;
741      -The name that can be named is not the eternal name.
742       The Nameless is the origin of Heaven and Earth;
743      -The Named is the mother of all things.
744      +The named is the mother of all things.
745      +
746       Therefore let there always be non-being,
747         so we may see their subtlety,
748       And let there always be being,
749      @@ -9,3 +8,6 @@
750       The two are the same,
751       But after they are produced,
752         they have different names.
753      +They both may be called deep and profound.
754      +Deeper and more profound,
755      +The door of all subtleties!
756
757 \1f
758 File: diffutils.info,  Node: Detailed Unified,  Prev: Example Unified,  Up: Unified Format
759
760 2.2.2.2 Detailed Description of Unified Format
761 ..............................................
762
763 The unified output format starts with a two-line header, which looks
764 like this:
765
766      --- FROM-FILE FROM-FILE-MODIFICATION-TIME
767      +++ TO-FILE TO-FILE-MODIFICATION-TIME
768
769 The timestamp looks like '2002-02-21 23:30:39.942229878 -0800' to
770 indicate the date, time with fractional seconds, and time zone.  The
771 fractional seconds are omitted on hosts that do not support fractional
772 timestamps.
773
774    You can change the header's content with the '--label=LABEL' option.
775 *Note Alternate Names::.
776
777    Next come one or more hunks of differences; each hunk shows one area
778 where the files differ.  Unified format hunks look like this:
779
780      @@ FROM-FILE-LINE-NUMBERS TO-FILE-LINE-NUMBERS @@
781       LINE-FROM-EITHER-FILE
782       LINE-FROM-EITHER-FILE...
783
784    If a hunk contains just one line, only its start line number appears.
785 Otherwise its line numbers look like 'START,COUNT'.  An empty hunk is
786 considered to start at the line that follows the hunk.
787
788    If a hunk and its context contain two or more lines, its line numbers
789 look like 'START,COUNT'.  Otherwise only its end line number appears.
790 An empty hunk is considered to end at the line that precedes the hunk.
791
792    The lines common to both files begin with a space character.  The
793 lines that actually differ between the two files have one of the
794 following indicator characters in the left print column:
795
796 '+'
797      A line was added here to the first file.
798
799 '-'
800      A line was removed here from the first file.
801
802 \1f
803 File: diffutils.info,  Node: Sections,  Next: Alternate Names,  Prev: Unified Format,  Up: Context
804
805 2.2.3 Showing Which Sections Differences Are in
806 -----------------------------------------------
807
808 Sometimes you might want to know which part of the files each change
809 falls in.  If the files are source code, this could mean which function
810 was changed.  If the files are documents, it could mean which chapter or
811 appendix was changed.  GNU 'diff' can show this by displaying the
812 nearest section heading line that precedes the differing lines.  Which
813 lines are "section headings" is determined by a regular expression.
814
815 * Menu:
816
817 * Specified Headings::  Showing headings that match regular expressions.
818 * C Function Headings:: Showing headings of C functions.
819
820 \1f
821 File: diffutils.info,  Node: Specified Headings,  Next: C Function Headings,  Up: Sections
822
823 2.2.3.1 Showing Lines That Match Regular Expressions
824 ....................................................
825
826 To show in which sections differences occur for files that are not
827 source code for C or similar languages, use the
828 '--show-function-line=REGEXP' ('-F REGEXP') option.  'diff' considers
829 lines that match the 'grep'-style regular expression REGEXP to be the
830 beginning of a section of the file.  Here are suggested regular
831 expressions for some common languages:
832
833 '^[[:alpha:]$_]'
834      C, C++, Prolog
835 '^('
836      Lisp
837 '^@node'
838      Texinfo
839
840    This option does not automatically select an output format; in order
841 to use it, you must select the context format (*note Context Format::)
842 or unified format (*note Unified Format::).  In other output formats it
843 has no effect.
844
845    The '--show-function-line' ('-F') option finds the nearest unchanged
846 line that precedes each hunk of differences and matches the given
847 regular expression.  Then it adds that line to the end of the line of
848 asterisks in the context format, or to the '@@' line in unified format.
849 If no matching line exists, this option leaves the output for that hunk
850 unchanged.  If that line is more than 40 characters long, it outputs
851 only the first 40 characters.  You can specify more than one regular
852 expression for such lines; 'diff' tries to match each line against each
853 regular expression, starting with the last one given.  This means that
854 you can use '-p' and '-F' together, if you wish.
855
856 \1f
857 File: diffutils.info,  Node: C Function Headings,  Prev: Specified Headings,  Up: Sections
858
859 2.2.3.2 Showing C Function Headings
860 ...................................
861
862 To show in which functions differences occur for C and similar
863 languages, you can use the '--show-c-function' ('-p') option.  This
864 option automatically defaults to the context output format (*note
865 Context Format::), with the default number of lines of context.  You can
866 override that number with '-C LINES' elsewhere in the command line.  You
867 can override both the format and the number with '-U LINES' elsewhere in
868 the command line.
869
870    The '--show-c-function' ('-p') option is equivalent to '-F
871 '^[[:alpha:]$_]'' if the unified format is specified, otherwise '-c -F
872 '^[[:alpha:]$_]'' (*note Specified Headings::).  GNU 'diff' provides
873 this option for the sake of convenience.
874
875 \1f
876 File: diffutils.info,  Node: Alternate Names,  Prev: Sections,  Up: Context
877
878 2.2.4 Showing Alternate File Names
879 ----------------------------------
880
881 If you are comparing two files that have meaningless or uninformative
882 names, you might want 'diff' to show alternate names in the header of
883 the context and unified output formats.  To do this, use the
884 '--label=LABEL' option.  The first time you give this option, its
885 argument replaces the name and date of the first file in the header; the
886 second time, its argument replaces the name and date of the second file.
887 If you give this option more than twice, 'diff' reports an error.  The
888 '--label' option does not affect the file names in the 'pr' header when
889 the '-l' or '--paginate' option is used (*note Pagination::).
890
891    Here are the first two lines of the output from 'diff -C 2
892 --label=original --label=modified lao tzu':
893
894      *** original
895      --- modified
896
897 \1f
898 File: diffutils.info,  Node: Side by Side,  Next: Normal,  Prev: Context,  Up: Output Formats
899
900 2.3 Showing Differences Side by Side
901 ====================================
902
903 'diff' can produce a side by side difference listing of two files.  The
904 files are listed in two columns with a gutter between them.  The gutter
905 contains one of the following markers:
906
907 white space
908      The corresponding lines are in common.  That is, either the lines
909      are identical, or the difference is ignored because of one of the
910      '--ignore' options (*note White Space::).
911
912 '|'
913      The corresponding lines differ, and they are either both complete
914      or both incomplete.
915
916 '<'
917      The files differ and only the first file contains the line.
918
919 '>'
920      The files differ and only the second file contains the line.
921
922 '('
923      Only the first file contains the line, but the difference is
924      ignored.
925
926 ')'
927      Only the second file contains the line, but the difference is
928      ignored.
929
930 '\'
931      The corresponding lines differ, and only the first line is
932      incomplete.
933
934 '/'
935      The corresponding lines differ, and only the second line is
936      incomplete.
937
938    Normally, an output line is incomplete if and only if the lines that
939 it contains are incomplete.  *Note Incomplete Lines::.  However, when an
940 output line represents two differing lines, one might be incomplete
941 while the other is not.  In this case, the output line is complete, but
942 its the gutter is marked '\' if the first line is incomplete, '/' if the
943 second line is.
944
945    Side by side format is sometimes easiest to read, but it has
946 limitations.  It generates much wider output than usual, and truncates
947 lines that are too long to fit.  Also, it relies on lining up output
948 more heavily than usual, so its output looks particularly bad if you use
949 varying width fonts, nonstandard tab stops, or nonprinting characters.
950
951    You can use the 'sdiff' command to interactively merge side by side
952 differences.  *Note Interactive Merging::, for more information on
953 merging files.
954
955 * Menu:
956
957 * Side by Side Format::  Controlling side by side output format.
958 * Example Side by Side:: Sample side by side output.
959
960 \1f
961 File: diffutils.info,  Node: Side by Side Format,  Next: Example Side by Side,  Up: Side by Side
962
963 2.3.1 Controlling Side by Side Format
964 -------------------------------------
965
966 The '--side-by-side' ('-y') option selects side by side format.  Because
967 side by side output lines contain two input lines, the output is wider
968 than usual: normally 130 print columns, which can fit onto a traditional
969 printer line.  You can set the width of the output with the
970 '--width=COLUMNS' ('-W COLUMNS') option.  The output is split into two
971 halves of equal width, separated by a small gutter to mark differences;
972 the right half is aligned to a tab stop so that tabs line up.  Input
973 lines that are too long to fit in half of an output line are truncated
974 for output.
975
976    The '--left-column' option prints only the left column of two common
977 lines.  The '--suppress-common-lines' option suppresses common lines
978 entirely.
979
980 \1f
981 File: diffutils.info,  Node: Example Side by Side,  Prev: Side by Side Format,  Up: Side by Side
982
983 2.3.2 An Example of Side by Side Format
984 ---------------------------------------
985
986 Here is the output of the command 'diff -y -W 72 lao tzu' (*note Sample
987 diff Input::, for the complete contents of the two files).
988
989      The Way that can be told of is n   <
990      The name that can be named is no   <
991      The Nameless is the origin of He        The Nameless is the origin of He
992      The Named is the mother of all t   |    The named is the mother of all t
993                                         >
994      Therefore let there always be no        Therefore let there always be no
995        so we may see their subtlety,           so we may see their subtlety,
996      And let there always be being,          And let there always be being,
997        so we may see their outcome.            so we may see their outcome.
998      The two are the same,                   The two are the same,
999      But after they are produced,            But after they are produced,
1000        they have different names.              they have different names.
1001                                         >    They both may be called deep and
1002                                         >    Deeper and more profound,
1003                                         >    The door of all subtleties!
1004
1005 \1f
1006 File: diffutils.info,  Node: Normal,  Next: Scripts,  Prev: Side by Side,  Up: Output Formats
1007
1008 2.4 Showing Differences Without Context
1009 =======================================
1010
1011 The "normal" 'diff' output format shows each hunk of differences without
1012 any surrounding context.  Sometimes such output is the clearest way to
1013 see how lines have changed, without the clutter of nearby unchanged
1014 lines (although you can get similar results with the context or unified
1015 formats by using 0 lines of context).  However, this format is no longer
1016 widely used for sending out patches; for that purpose, the context
1017 format (*note Context Format::) and the unified format (*note Unified
1018 Format::) are superior.  Normal format is the default for compatibility
1019 with older versions of 'diff' and the POSIX standard.  Use the
1020 '--normal' option to select this output format explicitly.
1021
1022 * Menu:
1023
1024 * Example Normal::  Sample output in the normal format.
1025 * Detailed Normal:: A detailed description of normal output format.
1026
1027 \1f
1028 File: diffutils.info,  Node: Example Normal,  Next: Detailed Normal,  Up: Normal
1029
1030 2.4.1 An Example of Normal Format
1031 ---------------------------------
1032
1033 Here is the output of the command 'diff lao tzu' (*note Sample diff
1034 Input::, for the complete contents of the two files).  Notice that it
1035 shows only the lines that are different between the two files.
1036
1037      1,2d0
1038      < The Way that can be told of is not the eternal Way;
1039      < The name that can be named is not the eternal name.
1040      4c2,3
1041      < The Named is the mother of all things.
1042      ---
1043      > The named is the mother of all things.
1044      >
1045      11a11,13
1046      > They both may be called deep and profound.
1047      > Deeper and more profound,
1048      > The door of all subtleties!
1049
1050 \1f
1051 File: diffutils.info,  Node: Detailed Normal,  Prev: Example Normal,  Up: Normal
1052
1053 2.4.2 Detailed Description of Normal Format
1054 -------------------------------------------
1055
1056 The normal output format consists of one or more hunks of differences;
1057 each hunk shows one area where the files differ.  Normal format hunks
1058 look like this:
1059
1060      CHANGE-COMMAND
1061      < FROM-FILE-LINE
1062      < FROM-FILE-LINE...
1063      ---
1064      > TO-FILE-LINE
1065      > TO-FILE-LINE...
1066
1067    There are three types of change commands.  Each consists of a line
1068 number or comma-separated range of lines in the first file, a single
1069 character indicating the kind of change to make, and a line number or
1070 comma-separated range of lines in the second file.  All line numbers are
1071 the original line numbers in each file.  The types of change commands
1072 are:
1073
1074 'LaR'
1075      Add the lines in range R of the second file after line L of the
1076      first file.  For example, '8a12,15' means append lines 12-15 of
1077      file 2 after line 8 of file 1; or, if changing file 2 into file 1,
1078      delete lines 12-15 of file 2.
1079
1080 'FcT'
1081      Replace the lines in range F of the first file with lines in range
1082      T of the second file.  This is like a combined add and delete, but
1083      more compact.  For example, '5,7c8,10' means change lines 5-7 of
1084      file 1 to read as lines 8-10 of file 2; or, if changing file 2 into
1085      file 1, change lines 8-10 of file 2 to read as lines 5-7 of file 1.
1086
1087 'RdL'
1088      Delete the lines in range R from the first file; line L is where
1089      they would have appeared in the second file had they not been
1090      deleted.  For example, '5,7d3' means delete lines 5-7 of file 1;
1091      or, if changing file 2 into file 1, append lines 5-7 of file 1
1092      after line 3 of file 2.
1093
1094 \1f
1095 File: diffutils.info,  Node: Scripts,  Next: If-then-else,  Prev: Normal,  Up: Output Formats
1096
1097 2.5 Making Edit Scripts
1098 =======================
1099
1100 Several output modes produce command scripts for editing FROM-FILE to
1101 produce TO-FILE.
1102
1103 * Menu:
1104
1105 * ed Scripts:: Using 'diff' to produce commands for 'ed'.
1106 * Forward ed:: Making forward 'ed' scripts.
1107 * RCS::        A special 'diff' output format used by RCS.
1108
1109 \1f
1110 File: diffutils.info,  Node: ed Scripts,  Next: Forward ed,  Up: Scripts
1111
1112 2.5.1 'ed' Scripts
1113 ------------------
1114
1115 'diff' can produce commands that direct the 'ed' text editor to change
1116 the first file into the second file.  Long ago, this was the only output
1117 mode that was suitable for editing one file into another automatically;
1118 today, with 'patch', it is almost obsolete.  Use the '--ed' ('-e')
1119 option to select this output format.
1120
1121    Like the normal format (*note Normal::), this output format does not
1122 show any context; unlike the normal format, it does not include the
1123 information necessary to apply the diff in reverse (to produce the first
1124 file if all you have is the second file and the diff).
1125
1126    If the file 'd' contains the output of 'diff -e old new', then the
1127 command '(cat d && echo w) | ed - old' edits 'old' to make it a copy of
1128 'new'.  More generally, if 'd1', 'd2', ..., 'dN' contain the outputs of
1129 'diff -e old new1', 'diff -e new1 new2', ..., 'diff -e newN-1 newN',
1130 respectively, then the command '(cat d1 d2 ... dN && echo w) | ed - old'
1131 edits 'old' to make it a copy of 'newN'.
1132
1133 * Menu:
1134
1135 * Example ed::  A sample 'ed' script.
1136 * Detailed ed:: A detailed description of 'ed' format.
1137
1138 \1f
1139 File: diffutils.info,  Node: Example ed,  Next: Detailed ed,  Up: ed Scripts
1140
1141 2.5.1.1 Example 'ed' Script
1142 ...........................
1143
1144 Here is the output of 'diff -e lao tzu' (*note Sample diff Input::, for
1145 the complete contents of the two files):
1146
1147      11a
1148      They both may be called deep and profound.
1149      Deeper and more profound,
1150      The door of all subtleties!
1151      .
1152      4c
1153      The named is the mother of all things.
1154
1155      .
1156      1,2d
1157
1158 \1f
1159 File: diffutils.info,  Node: Detailed ed,  Prev: Example ed,  Up: ed Scripts
1160
1161 2.5.1.2 Detailed Description of 'ed' Format
1162 ...........................................
1163
1164 The 'ed' output format consists of one or more hunks of differences.
1165 The changes closest to the ends of the files come first so that commands
1166 that change the number of lines do not affect how 'ed' interprets line
1167 numbers in succeeding commands.  'ed' format hunks look like this:
1168
1169      CHANGE-COMMAND
1170      TO-FILE-LINE
1171      TO-FILE-LINE...
1172      .
1173
1174    Because 'ed' uses a single period on a line to indicate the end of
1175 input, GNU 'diff' protects lines of changes that contain a single period
1176 on a line by writing two periods instead, then writing a subsequent 'ed'
1177 command to change the two periods into one.  The 'ed' format cannot
1178 represent an incomplete line, so if the second file ends in a changed
1179 incomplete line, 'diff' reports an error and then pretends that a
1180 newline was appended.
1181
1182    There are three types of change commands.  Each consists of a line
1183 number or comma-separated range of lines in the first file and a single
1184 character indicating the kind of change to make.  All line numbers are
1185 the original line numbers in the file.  The types of change commands
1186 are:
1187
1188 'La'
1189      Add text from the second file after line L in the first file.  For
1190      example, '8a' means to add the following lines after line 8 of file
1191      1.
1192
1193 'Rc'
1194      Replace the lines in range R in the first file with the following
1195      lines.  Like a combined add and delete, but more compact.  For
1196      example, '5,7c' means change lines 5-7 of file 1 to read as the
1197      text file 2.
1198
1199 'Rd'
1200      Delete the lines in range R from the first file.  For example,
1201      '5,7d' means delete lines 5-7 of file 1.
1202
1203 \1f
1204 File: diffutils.info,  Node: Forward ed,  Next: RCS,  Prev: ed Scripts,  Up: Scripts
1205
1206 2.5.2 Forward 'ed' Scripts
1207 --------------------------
1208
1209 'diff' can produce output that is like an 'ed' script, but with hunks in
1210 forward (front to back) order.  The format of the commands is also
1211 changed slightly: command characters precede the lines they modify,
1212 spaces separate line numbers in ranges, and no attempt is made to
1213 disambiguate hunk lines consisting of a single period.  Like 'ed'
1214 format, forward 'ed' format cannot represent incomplete lines.
1215
1216    Forward 'ed' format is not very useful, because neither 'ed' nor
1217 'patch' can apply diffs in this format.  It exists mainly for
1218 compatibility with older versions of 'diff'.  Use the '-f' or
1219 '--forward-ed' option to select it.
1220
1221 \1f
1222 File: diffutils.info,  Node: RCS,  Prev: Forward ed,  Up: Scripts
1223
1224 2.5.3 RCS Scripts
1225 -----------------
1226
1227 The RCS output format is designed specifically for use by the Revision
1228 Control System, which is a set of free programs used for organizing
1229 different versions and systems of files.  Use the '--rcs' ('-n') option
1230 to select this output format.  It is like the forward 'ed' format (*note
1231 Forward ed::), but it can represent arbitrary changes to the contents of
1232 a file because it avoids the forward 'ed' format's problems with lines
1233 consisting of a single period and with incomplete lines.  Instead of
1234 ending text sections with a line consisting of a single period, each
1235 command specifies the number of lines it affects; a combination of the
1236 'a' and 'd' commands are used instead of 'c'.  Also, if the second file
1237 ends in a changed incomplete line, then the output also ends in an
1238 incomplete line.
1239
1240    Here is the output of 'diff -n lao tzu' (*note Sample diff Input::,
1241 for the complete contents of the two files):
1242
1243      d1 2
1244      d4 1
1245      a4 2
1246      The named is the mother of all things.
1247
1248      a11 3
1249      They both may be called deep and profound.
1250      Deeper and more profound,
1251      The door of all subtleties!
1252
1253 \1f
1254 File: diffutils.info,  Node: If-then-else,  Prev: Scripts,  Up: Output Formats
1255
1256 2.6 Merging Files with If-then-else
1257 ===================================
1258
1259 You can use 'diff' to merge two files of C source code.  The output of
1260 'diff' in this format contains all the lines of both files.  Lines
1261 common to both files are output just once; the differing parts are
1262 separated by the C preprocessor directives '#ifdef NAME' or '#ifndef
1263 NAME', '#else', and '#endif'.  When compiling the output, you select
1264 which version to use by either defining or leaving undefined the macro
1265 NAME.
1266
1267    To merge two files, use 'diff' with the '-D NAME' or '--ifdef=NAME'
1268 option.  The argument NAME is the C preprocessor identifier to use in
1269 the '#ifdef' and '#ifndef' directives.
1270
1271    For example, if you change an instance of 'wait (&s)' to 'waitpid
1272 (-1, &s, 0)' and then merge the old and new files with the
1273 '--ifdef=HAVE_WAITPID' option, then the affected part of your code might
1274 look like this:
1275
1276          do {
1277      #ifndef HAVE_WAITPID
1278              if ((w = wait (&s)) < 0  &&  errno != EINTR)
1279      #else /* HAVE_WAITPID */
1280              if ((w = waitpid (-1, &s, 0)) < 0  &&  errno != EINTR)
1281      #endif /* HAVE_WAITPID */
1282                  return w;
1283          } while (w != child);
1284
1285    You can specify formats for languages other than C by using line
1286 group formats and line formats, as described in the next sections.
1287
1288 * Menu:
1289
1290 * Line Group Formats::    Formats for general if-then-else line groups.
1291 * Line Formats::          Formats for each line in a line group.
1292 * Example If-then-else::  Sample if-then-else format output.
1293 * Detailed If-then-else:: A detailed description of if-then-else format.
1294
1295 \1f
1296 File: diffutils.info,  Node: Line Group Formats,  Next: Line Formats,  Up: If-then-else
1297
1298 2.6.1 Line Group Formats
1299 ------------------------
1300
1301 Line group formats let you specify formats suitable for many
1302 applications that allow if-then-else input, including programming
1303 languages and text formatting languages.  A line group format specifies
1304 the output format for a contiguous group of similar lines.
1305
1306    For example, the following command compares the TeX files 'old' and
1307 'new', and outputs a merged file in which old regions are surrounded by
1308 '\begin{em}'-'\end{em}' lines, and new regions are surrounded by
1309 '\begin{bf}'-'\end{bf}' lines.
1310
1311      diff \
1312         --old-group-format='\begin{em}
1313      %<\end{em}
1314      ' \
1315         --new-group-format='\begin{bf}
1316      %>\end{bf}
1317      ' \
1318         old new
1319
1320    The following command is equivalent to the above example, but it is a
1321 little more verbose, because it spells out the default line group
1322 formats.
1323
1324      diff \
1325         --old-group-format='\begin{em}
1326      %<\end{em}
1327      ' \
1328         --new-group-format='\begin{bf}
1329      %>\end{bf}
1330      ' \
1331         --unchanged-group-format='%=' \
1332         --changed-group-format='\begin{em}
1333      %<\end{em}
1334      \begin{bf}
1335      %>\end{bf}
1336      ' \
1337         old new
1338
1339    Here is a more advanced example, which outputs a diff listing with
1340 headers containing line numbers in a "plain English" style.
1341
1342      diff \
1343         --unchanged-group-format='' \
1344         --old-group-format='-------- %dn line%(n=1?:s) deleted at %df:
1345      %<' \
1346         --new-group-format='-------- %dN line%(N=1?:s) added after %de:
1347      %>' \
1348         --changed-group-format='-------- %dn line%(n=1?:s) changed at %df:
1349      %<-------- to:
1350      %>' \
1351         old new
1352
1353    To specify a line group format, use 'diff' with one of the options
1354 listed below.  You can specify up to four line group formats, one for
1355 each kind of line group.  You should quote FORMAT, because it typically
1356 contains shell metacharacters.
1357
1358 '--old-group-format=FORMAT'
1359      These line groups are hunks containing only lines from the first
1360      file.  The default old group format is the same as the changed
1361      group format if it is specified; otherwise it is a format that
1362      outputs the line group as-is.
1363
1364 '--new-group-format=FORMAT'
1365      These line groups are hunks containing only lines from the second
1366      file.  The default new group format is same as the changed group
1367      format if it is specified; otherwise it is a format that outputs
1368      the line group as-is.
1369
1370 '--changed-group-format=FORMAT'
1371      These line groups are hunks containing lines from both files.  The
1372      default changed group format is the concatenation of the old and
1373      new group formats.
1374
1375 '--unchanged-group-format=FORMAT'
1376      These line groups contain lines common to both files.  The default
1377      unchanged group format is a format that outputs the line group
1378      as-is.
1379
1380    In a line group format, ordinary characters represent themselves;
1381 conversion specifications start with '%' and have one of the following
1382 forms.
1383
1384 '%<'
1385      stands for the lines from the first file, including the trailing
1386      newline.  Each line is formatted according to the old line format
1387      (*note Line Formats::).
1388
1389 '%>'
1390      stands for the lines from the second file, including the trailing
1391      newline.  Each line is formatted according to the new line format.
1392
1393 '%='
1394      stands for the lines common to both files, including the trailing
1395      newline.  Each line is formatted according to the unchanged line
1396      format.
1397
1398 '%%'
1399      stands for '%'.
1400
1401 '%c'C''
1402      where C is a single character, stands for C.  C may not be a
1403      backslash or an apostrophe.  For example, '%c':'' stands for a
1404      colon, even inside the then-part of an if-then-else format, which a
1405      colon would normally terminate.
1406
1407 '%c'\O''
1408      where O is a string of 1, 2, or 3 octal digits, stands for the
1409      character with octal code O.  For example, '%c'\0'' stands for a
1410      null character.
1411
1412 'FN'
1413      where F is a 'printf' conversion specification and N is one of the
1414      following letters, stands for N's value formatted with F.
1415
1416      'e'
1417           The line number of the line just before the group in the old
1418           file.
1419
1420      'f'
1421           The line number of the first line in the group in the old
1422           file; equals E + 1.
1423
1424      'l'
1425           The line number of the last line in the group in the old file.
1426
1427      'm'
1428           The line number of the line just after the group in the old
1429           file; equals L + 1.
1430
1431      'n'
1432           The number of lines in the group in the old file; equals L - F
1433           + 1.
1434
1435      'E, F, L, M, N'
1436           Likewise, for lines in the new file.
1437
1438      The 'printf' conversion specification can be '%d', '%o', '%x', or
1439      '%X', specifying decimal, octal, lower case hexadecimal, or upper
1440      case hexadecimal output respectively.  After the '%' the following
1441      options can appear in sequence: a series of zero or more flags; an
1442      integer specifying the minimum field width; and a period followed
1443      by an optional integer specifying the minimum number of digits.
1444      The flags are '-' for left-justification, ''' for separating the
1445      digit into groups as specified by the 'LC_NUMERIC' locale category,
1446      and '0' for padding with zeros instead of spaces.  For example,
1447      '%5dN' prints the number of new lines in the group in a field of
1448      width 5 characters, using the 'printf' format '"%5d"'.
1449
1450 '(A=B?T:E)'
1451      If A equals B then T else E.  A and B are each either a decimal
1452      constant or a single letter interpreted as above.  This format spec
1453      is equivalent to T if A's value equals B's; otherwise it is
1454      equivalent to E.
1455
1456      For example, '%(N=0?no:%dN) line%(N=1?:s)' is equivalent to 'no
1457      lines' if N (the number of lines in the group in the new file) is
1458      0, to '1 line' if N is 1, and to '%dN lines' otherwise.
1459
1460 \1f
1461 File: diffutils.info,  Node: Line Formats,  Next: Example If-then-else,  Prev: Line Group Formats,  Up: If-then-else
1462
1463 2.6.2 Line Formats
1464 ------------------
1465
1466 Line formats control how each line taken from an input file is output as
1467 part of a line group in if-then-else format.
1468
1469    For example, the following command outputs text with a one-character
1470 change indicator to the left of the text.  The first character of output
1471 is '-' for deleted lines, '|' for added lines, and a space for unchanged
1472 lines.  The formats contain newline characters where newlines are
1473 desired on output.
1474
1475      diff \
1476         --old-line-format='-%l
1477      ' \
1478         --new-line-format='|%l
1479      ' \
1480         --unchanged-line-format=' %l
1481      ' \
1482         old new
1483
1484    To specify a line format, use one of the following options.  You
1485 should quote FORMAT, since it often contains shell metacharacters.
1486
1487 '--old-line-format=FORMAT'
1488      formats lines just from the first file.
1489
1490 '--new-line-format=FORMAT'
1491      formats lines just from the second file.
1492
1493 '--unchanged-line-format=FORMAT'
1494      formats lines common to both files.
1495
1496 '--line-format=FORMAT'
1497      formats all lines; in effect, it sets all three above options
1498      simultaneously.
1499
1500    In a line format, ordinary characters represent themselves;
1501 conversion specifications start with '%' and have one of the following
1502 forms.
1503
1504 '%l'
1505      stands for the contents of the line, not counting its trailing
1506      newline (if any).  This format ignores whether the line is
1507      incomplete; *Note Incomplete Lines::.
1508
1509 '%L'
1510      stands for the contents of the line, including its trailing newline
1511      (if any).  If a line is incomplete, this format preserves its
1512      incompleteness.
1513
1514 '%%'
1515      stands for '%'.
1516
1517 '%c'C''
1518      where C is a single character, stands for C.  C may not be a
1519      backslash or an apostrophe.  For example, '%c':'' stands for a
1520      colon.
1521
1522 '%c'\O''
1523      where O is a string of 1, 2, or 3 octal digits, stands for the
1524      character with octal code O.  For example, '%c'\0'' stands for a
1525      null character.
1526
1527 'Fn'
1528      where F is a 'printf' conversion specification, stands for the line
1529      number formatted with F.  For example, '%.5dn' prints the line
1530      number using the 'printf' format '"%.5d"'.  *Note Line Group
1531      Formats::, for more about printf conversion specifications.
1532
1533    The default line format is '%l' followed by a newline character.
1534
1535    If the input contains tab characters and it is important that they
1536 line up on output, you should ensure that '%l' or '%L' in a line format
1537 is just after a tab stop (e.g. by preceding '%l' or '%L' with a tab
1538 character), or you should use the '-t' or '--expand-tabs' option.
1539
1540    Taken together, the line and line group formats let you specify many
1541 different formats.  For example, the following command uses a format
1542 similar to normal 'diff' format.  You can tailor this command to get
1543 fine control over 'diff' output.
1544
1545      diff \
1546         --old-line-format='< %l
1547      ' \
1548         --new-line-format='> %l
1549      ' \
1550         --old-group-format='%df%(f=l?:,%dl)d%dE
1551      %<' \
1552         --new-group-format='%dea%dF%(F=L?:,%dL)
1553      %>' \
1554         --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL)
1555      %<---
1556      %>' \
1557         --unchanged-group-format='' \
1558         old new
1559
1560 \1f
1561 File: diffutils.info,  Node: Example If-then-else,  Next: Detailed If-then-else,  Prev: Line Formats,  Up: If-then-else
1562
1563 2.6.3 An Example of If-then-else Format
1564 ---------------------------------------
1565
1566 Here is the output of 'diff -DTWO lao tzu' (*note Sample diff Input::,
1567 for the complete contents of the two files):
1568
1569      #ifndef TWO
1570      The Way that can be told of is not the eternal Way;
1571      The name that can be named is not the eternal name.
1572      #endif /* ! TWO */
1573      The Nameless is the origin of Heaven and Earth;
1574      #ifndef TWO
1575      The Named is the mother of all things.
1576      #else /* TWO */
1577      The named is the mother of all things.
1578
1579      #endif /* TWO */
1580      Therefore let there always be non-being,
1581        so we may see their subtlety,
1582      And let there always be being,
1583        so we may see their outcome.
1584      The two are the same,
1585      But after they are produced,
1586        they have different names.
1587      #ifdef TWO
1588      They both may be called deep and profound.
1589      Deeper and more profound,
1590      The door of all subtleties!
1591      #endif /* TWO */
1592
1593 \1f
1594 File: diffutils.info,  Node: Detailed If-then-else,  Prev: Example If-then-else,  Up: If-then-else
1595
1596 2.6.4 Detailed Description of If-then-else Format
1597 -------------------------------------------------
1598
1599 For lines common to both files, 'diff' uses the unchanged line group
1600 format.  For each hunk of differences in the merged output format, if
1601 the hunk contains only lines from the first file, 'diff' uses the old
1602 line group format; if the hunk contains only lines from the second file,
1603 'diff' uses the new group format; otherwise, 'diff' uses the changed
1604 group format.
1605
1606    The old, new, and unchanged line formats specify the output format of
1607 lines from the first file, lines from the second file, and lines common
1608 to both files, respectively.
1609
1610    The option '--ifdef=NAME' is equivalent to the following sequence of
1611 options using shell syntax:
1612
1613      --old-group-format='#ifndef NAME
1614      %<#endif /* ! NAME */
1615      ' \
1616      --new-group-format='#ifdef NAME
1617      %>#endif /* NAME */
1618      ' \
1619      --unchanged-group-format='%=' \
1620      --changed-group-format='#ifndef NAME
1621      %<#else /* NAME */
1622      %>#endif /* NAME */
1623      '
1624
1625    You should carefully check the 'diff' output for proper nesting.  For
1626 example, when using the '-D NAME' or '--ifdef=NAME' option, you should
1627 check that if the differing lines contain any of the C preprocessor
1628 directives '#ifdef', '#ifndef', '#else', '#elif', or '#endif', they are
1629 nested properly and match.  If they don't, you must make corrections
1630 manually.  It is a good idea to carefully check the resulting code
1631 anyway to make sure that it really does what you want it to; depending
1632 on how the input files were produced, the output might contain duplicate
1633 or otherwise incorrect code.
1634
1635    The 'patch' '-D NAME' option behaves like the 'diff' '-D NAME'
1636 option, except it operates on a file and a diff to produce a merged
1637 file.  *Note patch Options::.
1638
1639 \1f
1640 File: diffutils.info,  Node: Incomplete Lines,  Next: Comparing Directories,  Prev: Output Formats,  Up: Top
1641
1642 3 Incomplete Lines
1643 ******************
1644
1645 When an input file ends in a non-newline character, its last line is
1646 called an "incomplete line" because its last character is not a newline.
1647 All other lines are called "full lines" and end in a newline character.
1648 Incomplete lines do not match full lines unless differences in white
1649 space are ignored (*note White Space::).
1650
1651    An incomplete line is normally distinguished on output from a full
1652 line by a following line that starts with '\'.  However, the RCS format
1653 (*note RCS::) outputs the incomplete line as-is, without any trailing
1654 newline or following line.  The side by side format normally represents
1655 incomplete lines as-is, but in some cases uses a '\' or '/' gutter
1656 marker.  *Note Side by Side::.  The if-then-else line format preserves a
1657 line's incompleteness with '%L', and discards the newline with '%l'.
1658 *Note Line Formats::.  Finally, with the 'ed' and forward 'ed' output
1659 formats (*note Output Formats::) 'diff' cannot represent an incomplete
1660 line, so it pretends there was a newline and reports an error.
1661
1662    For example, suppose 'F' and 'G' are one-byte files that contain just
1663 'f' and 'g', respectively.  Then 'diff F G' outputs
1664
1665      1c1
1666      < f
1667      \ No newline at end of file
1668      ---
1669      > g
1670      \ No newline at end of file
1671
1672 (The exact message may differ in non-English locales.)  'diff -n F G'
1673 outputs the following without a trailing newline:
1674
1675      d1 1
1676      a1 1
1677      g
1678
1679 'diff -e F G' reports two errors and outputs the following:
1680
1681      1c
1682      g
1683      .
1684
1685 \1f
1686 File: diffutils.info,  Node: Comparing Directories,  Next: Adjusting Output,  Prev: Incomplete Lines,  Up: Top
1687
1688 4 Comparing Directories
1689 ***********************
1690
1691 You can use 'diff' to compare some or all of the files in two directory
1692 trees.  When both file name arguments to 'diff' are directories, it
1693 compares each file that is contained in both directories, examining file
1694 names in alphabetical order as specified by the 'LC_COLLATE' locale
1695 category.  Normally 'diff' is silent about pairs of files that contain
1696 no differences, but if you use the '--report-identical-files' ('-s')
1697 option, it reports pairs of identical files.  Normally 'diff' reports
1698 subdirectories common to both directories without comparing
1699 subdirectories' files, but if you use the '-r' or '--recursive' option,
1700 it compares every corresponding pair of files in the directory trees, as
1701 many levels deep as they go.
1702
1703    If only one file exists, 'diff' normally does not show its contents;
1704 it merely reports that one file exists but the other does not.  You can
1705 make 'diff' act as though the missing file is empty, so that it outputs
1706 the entire contents of the file that actually exists.  (It is output as
1707 either an insertion or a deletion, depending on whether the missing file
1708 is in the first or the second position.)  To do this, use the
1709 '--new-file' ('-N') option.  This option affects command-line arguments
1710 as well as files found via directory traversal; for example, 'diff -N a
1711 b' treats 'a' as empty if 'a' does not exist but 'b' does.
1712
1713    If the older directory contains large files that are not in the newer
1714 directory, you can make the patch smaller by using the
1715 '--unidirectional-new-file' option instead of '-N'.  This option is like
1716 '-N' except that it inserts the contents only of files that appear in
1717 the second directory but not the first (that is, files that were added).
1718 At the top of the patch, write instructions for the user applying the
1719 patch to remove the files that were deleted before applying the patch.
1720 *Note Making Patches::, for more discussion of making patches for
1721 distribution.
1722
1723    To ignore some files while comparing directories, use the
1724 '--exclude=PATTERN' ('-x PATTERN') option.  This option ignores any
1725 files or subdirectories whose base names match the shell pattern
1726 PATTERN.  Unlike in the shell, a period at the start of the base of a
1727 file name matches a wildcard at the start of a pattern.  You should
1728 enclose PATTERN in quotes so that the shell does not expand it.  For
1729 example, the option '-x '*.[ao]'' ignores any file whose name ends with
1730 '.a' or '.o'.
1731
1732    This option accumulates if you specify it more than once.  For
1733 example, using the options '-x 'RCS' -x '*,v'' ignores any file or
1734 subdirectory whose base name is 'RCS' or ends with ',v'.
1735
1736    If you need to give this option many times, you can instead put the
1737 patterns in a file, one pattern per line, and use the
1738 '--exclude-from=FILE' ('-X FILE') option.  Trailing white space and
1739 empty lines are ignored in the pattern file.
1740
1741    If you have been comparing two directories and stopped partway
1742 through, later you might want to continue where you left off.  You can
1743 do this by using the '--starting-file=FILE' ('-S FILE') option.  This
1744 compares only the file FILE and all alphabetically later files in the
1745 topmost directory level.
1746
1747    If two directories differ only in that file names are lower case in
1748 one directory and upper case in the upper, 'diff' normally reports many
1749 differences because it compares file names in a case sensitive way.
1750 With the '--ignore-file-name-case' option, 'diff' ignores case
1751 differences in file names, so that for example the contents of the file
1752 'Tao' in one directory are compared to the contents of the file 'TAO' in
1753 the other.  The '--no-ignore-file-name-case' option cancels the effect
1754 of the '--ignore-file-name-case' option, reverting to the default
1755 behavior.
1756
1757    If an '--exclude=PATTERN' ('-x PATTERN') option, or an
1758 '--exclude-from=FILE' ('-X FILE') option, is specified while the
1759 '--ignore-file-name-case' option is in effect, case is ignored when
1760 excluding file names matching the specified patterns.
1761
1762    To tell 'diff' not to follow a symbolic link, use the
1763 '--no-dereference' option.
1764
1765 \1f
1766 File: diffutils.info,  Node: Adjusting Output,  Next: diff Performance,  Prev: Comparing Directories,  Up: Top
1767
1768 5 Making 'diff' Output Prettier
1769 *******************************
1770
1771 'diff' provides several ways to adjust the appearance of its output.
1772 These adjustments can be applied to any output format.
1773
1774 * Menu:
1775
1776 * Tabs::            Preserving the alignment of tab stops.
1777 * Trailing Blanks:: Suppressing blanks before empty output lines.
1778 * Pagination::      Page numbering and time-stamping 'diff' output.
1779
1780 \1f
1781 File: diffutils.info,  Node: Tabs,  Next: Trailing Blanks,  Up: Adjusting Output
1782
1783 5.1 Preserving Tab Stop Alignment
1784 =================================
1785
1786 The lines of text in some of the 'diff' output formats are preceded by
1787 one or two characters that indicate whether the text is inserted,
1788 deleted, or changed.  The addition of those characters can cause tabs to
1789 move to the next tab stop, throwing off the alignment of columns in the
1790 line.  GNU 'diff' provides two ways to make tab-aligned columns line up
1791 correctly.
1792
1793    The first way is to have 'diff' convert all tabs into the correct
1794 number of spaces before outputting them; select this method with the
1795 '--expand-tabs' ('-t') option.  To use this form of output with 'patch',
1796 you must give 'patch' the '-l' or '--ignore-white-space' option (*note
1797 Changed White Space::, for more information).  'diff' normally assumes
1798 that tab stops are set every 8 print columns, but this can be altered by
1799 the '--tabsize=COLUMNS' option.
1800
1801    The other method for making tabs line up correctly is to add a tab
1802 character instead of a space after the indicator character at the
1803 beginning of the line.  This ensures that all following tab characters
1804 are in the same position relative to tab stops that they were in the
1805 original files, so that the output is aligned correctly.  Its
1806 disadvantage is that it can make long lines too long to fit on one line
1807 of the screen or the paper.  It also does not work with the unified
1808 output format, which does not have a space character after the change
1809 type indicator character.  Select this method with the '-T' or
1810 '--initial-tab' option.
1811
1812 \1f
1813 File: diffutils.info,  Node: Trailing Blanks,  Next: Pagination,  Prev: Tabs,  Up: Adjusting Output
1814
1815 5.2 Omitting trailing blanks
1816 ============================
1817
1818 When outputting lines in normal or context format, or outputting an
1819 unchanged line in unified format, 'diff' normally outputs a blank just
1820 before each line.  If the line is empty, the output of 'diff' therefore
1821 contains trailing blanks even though the input does not contain them.
1822 For example, when outputting an unchanged empty line in context format,
1823 'diff' normally outputs a line with two leading spaces.
1824
1825    Some text editors and email agents routinely delete trailing blanks,
1826 so it can be a problem to deal with diff output files that contain them.
1827 You can avoid this problem with the '--suppress-blank-empty' option.  It
1828 causes 'diff' to omit trailing blanks at the end of output lines in
1829 normal, context, and unified format, unless the trailing blanks were
1830 already present in the input.  This changes the output format slightly,
1831 so that output lines are guaranteed to never end in a blank unless an
1832 input line ends in a blank.  This format is less likely to be munged by
1833 text editors or by transmission via email.  It is accepted by GNU
1834 'patch' as well.
1835
1836 \1f
1837 File: diffutils.info,  Node: Pagination,  Prev: Trailing Blanks,  Up: Adjusting Output
1838
1839 5.3 Paginating 'diff' Output
1840 ============================
1841
1842 It can be convenient to have long output page-numbered and time-stamped.
1843 The '--paginate' ('-l') option does this by sending the 'diff' output
1844 through the 'pr' program.  Here is what the page header might look like
1845 for 'diff -lc lao tzu':
1846
1847      2002-02-22 14:20                 diff -lc lao tzu                 Page 1
1848
1849 \1f
1850 File: diffutils.info,  Node: diff Performance,  Next: Comparing Three Files,  Prev: Adjusting Output,  Up: Top
1851
1852 6 'diff' Performance Tradeoffs
1853 ******************************
1854
1855 GNU 'diff' runs quite efficiently; however, in some circumstances you
1856 can cause it to run faster or produce a more compact set of changes.
1857
1858    One way to improve 'diff' performance is to use hard or symbolic
1859 links to files instead of copies.  This improves performance because
1860 'diff' normally does not need to read two hard or symbolic links to the
1861 same file, since their contents must be identical.  For example, suppose
1862 you copy a large directory hierarchy, make a few changes to the copy,
1863 and then often use 'diff -r' to compare the original to the copy.  If
1864 the original files are read-only, you can greatly improve performance by
1865 creating the copy using hard or symbolic links (e.g., with GNU 'cp -lR'
1866 or 'cp -sR').  Before editing a file in the copy for the first time, you
1867 should break the link and replace it with a regular copy.
1868
1869    You can also affect the performance of GNU 'diff' by giving it
1870 options that change the way it compares files.  Performance has more
1871 than one dimension.  These options improve one aspect of performance at
1872 the cost of another, or they improve performance in some cases while
1873 hurting it in others.
1874
1875    The way that GNU 'diff' determines which lines have changed always
1876 comes up with a near-minimal set of differences.  Usually it is good
1877 enough for practical purposes.  If the 'diff' output is large, you might
1878 want 'diff' to use a modified algorithm that sometimes produces a
1879 smaller set of differences.  The '--minimal' ('-d') option does this;
1880 however, it can also cause 'diff' to run more slowly than usual, so it
1881 is not the default behavior.
1882
1883    When the files you are comparing are large and have small groups of
1884 changes scattered throughout them, you can use the '--speed-large-files'
1885 option to make a different modification to the algorithm that 'diff'
1886 uses.  If the input files have a constant small density of changes, this
1887 option speeds up the comparisons without changing the output.  If not,
1888 'diff' might produce a larger set of differences; however, the output
1889 will still be correct.
1890
1891    Normally 'diff' discards the prefix and suffix that is common to both
1892 files before it attempts to find a minimal set of differences.  This
1893 makes 'diff' run faster, but occasionally it may produce non-minimal
1894 output.  The '--horizon-lines=LINES' option prevents 'diff' from
1895 discarding the last LINES lines of the prefix and the first LINES lines
1896 of the suffix.  This gives 'diff' further opportunities to find a
1897 minimal output.
1898
1899    Suppose a run of changed lines includes a sequence of lines at one
1900 end and there is an identical sequence of lines just outside the other
1901 end.  The 'diff' command is free to choose which identical sequence is
1902 included in the hunk.  In this case, 'diff' normally shifts the hunk's
1903 boundaries when this merges adjacent hunks, or shifts a hunk's lines
1904 towards the end of the file.  Merging hunks can make the output look
1905 nicer in some cases.
1906
1907 \1f
1908 File: diffutils.info,  Node: Comparing Three Files,  Next: diff3 Merging,  Prev: diff Performance,  Up: Top
1909
1910 7 Comparing Three Files
1911 ***********************
1912
1913 Use the program 'diff3' to compare three files and show any differences
1914 among them.  ('diff3' can also merge files; see *note diff3 Merging::).
1915
1916    The "normal" 'diff3' output format shows each hunk of differences
1917 without surrounding context.  Hunks are labeled depending on whether
1918 they are two-way or three-way, and lines are annotated by their location
1919 in the input files.
1920
1921    *Note Invoking diff3::, for more information on how to run 'diff3'.
1922
1923 * Menu:
1924
1925 * Sample diff3 Input::    Sample 'diff3' input for examples.
1926 * Example diff3 Normal::  Sample output in the normal format.
1927 * Detailed diff3 Normal:: A detailed description of normal output format.
1928 * diff3 Hunks::           The format of normal output format.
1929
1930 \1f
1931 File: diffutils.info,  Node: Sample diff3 Input,  Next: Example diff3 Normal,  Up: Comparing Three Files
1932
1933 7.1 A Third Sample Input File
1934 =============================
1935
1936 Here is a third sample file that will be used in examples to illustrate
1937 the output of 'diff3' and how various options can change it.  The first
1938 two files are the same that we used for 'diff' (*note Sample diff
1939 Input::).  This is the third sample file, called 'tao':
1940
1941      The Way that can be told of is not the eternal Way;
1942      The name that can be named is not the eternal name.
1943      The Nameless is the origin of Heaven and Earth;
1944      The named is the mother of all things.
1945
1946      Therefore let there always be non-being,
1947        so we may see their subtlety,
1948      And let there always be being,
1949        so we may see their result.
1950      The two are the same,
1951      But after they are produced,
1952        they have different names.
1953
1954        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
1955
1956 \1f
1957 File: diffutils.info,  Node: Example diff3 Normal,  Next: Detailed diff3 Normal,  Prev: Sample diff3 Input,  Up: Comparing Three Files
1958
1959 7.2 An Example of 'diff3' Normal Format
1960 =======================================
1961
1962 Here is the output of the command 'diff3 lao tzu tao' (*note Sample
1963 diff3 Input::, for the complete contents of the files).  Notice that it
1964 shows only the lines that are different among the three files.
1965
1966      ====2
1967      1:1,2c
1968      3:1,2c
1969        The Way that can be told of is not the eternal Way;
1970        The name that can be named is not the eternal name.
1971      2:0a
1972      ====1
1973      1:4c
1974        The Named is the mother of all things.
1975      2:2,3c
1976      3:4,5c
1977        The named is the mother of all things.
1978
1979      ====3
1980      1:8c
1981      2:7c
1982          so we may see their outcome.
1983      3:9c
1984          so we may see their result.
1985      ====
1986      1:11a
1987      2:11,13c
1988        They both may be called deep and profound.
1989        Deeper and more profound,
1990        The door of all subtleties!
1991      3:13,14c
1992
1993          -- The Way of Lao-Tzu, tr. Wing-tsit Chan
1994
1995 \1f
1996 File: diffutils.info,  Node: Detailed diff3 Normal,  Next: diff3 Hunks,  Prev: Example diff3 Normal,  Up: Comparing Three Files
1997
1998 7.3 Detailed Description of 'diff3' Normal Format
1999 =================================================
2000
2001 Each hunk begins with a line marked '===='.  Three-way hunks have plain
2002 '====' lines, and two-way hunks have '1', '2', or '3' appended to
2003 specify which of the three input files differ in that hunk.  The hunks
2004 contain copies of two or three sets of input lines each preceded by one
2005 or two commands identifying where the lines came from.
2006
2007    Normally, two spaces precede each copy of an input line to
2008 distinguish it from the commands.  But with the '--initial-tab' ('-T')
2009 option, 'diff3' uses a tab instead of two spaces; this lines up tabs
2010 correctly.  *Note Tabs::, for more information.
2011
2012    Commands take the following forms:
2013
2014 'FILE:La'
2015      This hunk appears after line L of file FILE, and contains no lines
2016      in that file.  To edit this file to yield the other files, one must
2017      append hunk lines taken from the other files.  For example, '1:11a'
2018      means that the hunk follows line 11 in the first file and contains
2019      no lines from that file.
2020
2021 'FILE:Rc'
2022      This hunk contains the lines in the range R of file FILE.  The
2023      range R is a comma-separated pair of line numbers, or just one
2024      number if there is only one line.  To edit this file to yield the
2025      other files, one must change the specified lines to be the lines
2026      taken from the other files.  For example, '2:11,13c' means that the
2027      hunk contains lines 11 through 13 from the second file.
2028
2029    If the last line in a set of input lines is incomplete (*note
2030 Incomplete Lines::), it is distinguished on output from a full line by a
2031 following line that starts with '\'.
2032
2033 \1f
2034 File: diffutils.info,  Node: diff3 Hunks,  Prev: Detailed diff3 Normal,  Up: Comparing Three Files
2035
2036 7.4 'diff3' Hunks
2037 =================
2038
2039 Groups of lines that differ in two or three of the input files are
2040 called "diff3 hunks", by analogy with 'diff' hunks (*note Hunks::).  If
2041 all three input files differ in a 'diff3' hunk, the hunk is called a
2042 "three-way hunk"; if just two input files differ, it is a "two-way
2043 hunk".
2044
2045    As with 'diff', several solutions are possible.  When comparing the
2046 files 'A', 'B', and 'C', 'diff3' normally finds 'diff3' hunks by merging
2047 the two-way hunks output by the two commands 'diff A B' and 'diff A C'.
2048 This does not necessarily minimize the size of the output, but
2049 exceptions should be rare.
2050
2051    For example, suppose 'F' contains the three lines 'a', 'b', 'f', 'G'
2052 contains the lines 'g', 'b', 'g', and 'H' contains the lines 'a', 'b',
2053 'h'.  'diff3 F G H' might output the following:
2054
2055      ====2
2056      1:1c
2057      3:1c
2058        a
2059      2:1c
2060        g
2061      ====
2062      1:3c
2063        f
2064      2:3c
2065        g
2066      3:3c
2067        h
2068
2069 because it found a two-way hunk containing 'a' in the first and third
2070 files and 'g' in the second file, then the single line 'b' common to all
2071 three files, then a three-way hunk containing the last line of each
2072 file.
2073
2074 \1f
2075 File: diffutils.info,  Node: diff3 Merging,  Next: Interactive Merging,  Prev: Comparing Three Files,  Up: Top
2076
2077 8 Merging From a Common Ancestor
2078 ********************************
2079
2080 When two people have made changes to copies of the same file, 'diff3'
2081 can produce a merged output that contains both sets of changes together
2082 with warnings about conflicts.
2083
2084    One might imagine programs with names like 'diff4' and 'diff5' to
2085 compare more than three files simultaneously, but in practice the need
2086 rarely arises.  You can use 'diff3' to merge three or more sets of
2087 changes to a file by merging two change sets at a time.
2088
2089    'diff3' can incorporate changes from two modified versions into a
2090 common preceding version.  This lets you merge the sets of changes
2091 represented by the two newer files.  Specify the common ancestor version
2092 as the second argument and the two newer versions as the first and third
2093 arguments, like this:
2094
2095      diff3 MINE OLDER YOURS
2096
2097 You can remember the order of the arguments by noting that they are in
2098 alphabetical order.
2099
2100    You can think of this as subtracting OLDER from YOURS and adding the
2101 result to MINE, or as merging into MINE the changes that would turn
2102 OLDER into YOURS.  This merging is well-defined as long as MINE and
2103 OLDER match in the neighborhood of each such change.  This fails to be
2104 true when all three input files differ or when only OLDER differs; we
2105 call this a "conflict".  When all three input files differ, we call the
2106 conflict an "overlap".
2107
2108    'diff3' gives you several ways to handle overlaps and conflicts.  You
2109 can omit overlaps or conflicts, or select only overlaps, or mark
2110 conflicts with special '<<<<<<<' and '>>>>>>>' lines.
2111
2112    'diff3' can output the merge results as an 'ed' script that that can
2113 be applied to the first file to yield the merged output.  However, it is
2114 usually better to have 'diff3' generate the merged output directly; this
2115 bypasses some problems with 'ed'.
2116
2117 * Menu:
2118
2119 * Which Changes::            Selecting changes to incorporate.
2120 * Marking Conflicts::        Marking conflicts.
2121 * Bypassing ed::             Generating merged output directly.
2122 * Merging Incomplete Lines:: How 'diff3' merges incomplete lines.
2123 * Saving the Changed File::  Emulating System V behavior.
2124
2125 \1f
2126 File: diffutils.info,  Node: Which Changes,  Next: Marking Conflicts,  Up: diff3 Merging
2127
2128 8.1 Selecting Which Changes to Incorporate
2129 ==========================================
2130
2131 You can select all unmerged changes from OLDER to YOURS for merging into
2132 MINE with the '--ed' ('-e') option.  You can select only the
2133 nonoverlapping unmerged changes with '--easy-only' ('-3'), and you can
2134 select only the overlapping changes with '--overlap-only' ('-x').
2135
2136    The '-e', '-3' and '-x' options select only "unmerged changes", i.e.
2137 changes where MINE and YOURS differ; they ignore changes from OLDER to
2138 YOURS where MINE and YOURS are identical, because they assume that such
2139 changes have already been merged.  If this assumption is not a safe one,
2140 you can use the '--show-all' ('-A') option (*note Marking Conflicts::).
2141
2142    Here is the output of the command 'diff3' with each of these three
2143 options (*note Sample diff3 Input::, for the complete contents of the
2144 files).  Notice that '-e' outputs the union of the disjoint sets of
2145 changes output by '-3' and '-x'.
2146
2147    Output of 'diff3 -e lao tzu tao':
2148      11a
2149
2150        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2151      .
2152      8c
2153        so we may see their result.
2154      .
2155
2156    Output of 'diff3 -3 lao tzu tao':
2157      8c
2158        so we may see their result.
2159      .
2160
2161    Output of 'diff3 -x lao tzu tao':
2162      11a
2163
2164        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2165      .
2166
2167 \1f
2168 File: diffutils.info,  Node: Marking Conflicts,  Next: Bypassing ed,  Prev: Which Changes,  Up: diff3 Merging
2169
2170 8.2 Marking Conflicts
2171 =====================
2172
2173 'diff3' can mark conflicts in the merged output by bracketing them with
2174 special marker lines.  A conflict that comes from two files A and B is
2175 marked as follows:
2176
2177      <<<<<<< A
2178      lines from A
2179      =======
2180      lines from B
2181      >>>>>>> B
2182
2183    A conflict that comes from three files A, B and C is marked as
2184 follows:
2185
2186      <<<<<<< A
2187      lines from A
2188      ||||||| B
2189      lines from B
2190      =======
2191      lines from C
2192      >>>>>>> C
2193
2194    The '--show-all' ('-A') option acts like the '-e' option, except that
2195 it brackets conflicts, and it outputs all changes from OLDER to YOURS,
2196 not just the unmerged changes.  Thus, given the sample input files
2197 (*note Sample diff3 Input::), 'diff3 -A lao tzu tao' puts brackets
2198 around the conflict where only 'tzu' differs:
2199
2200      <<<<<<< tzu
2201      =======
2202      The Way that can be told of is not the eternal Way;
2203      The name that can be named is not the eternal name.
2204      >>>>>>> tao
2205
2206    And it outputs the three-way conflict as follows:
2207
2208      <<<<<<< lao
2209      ||||||| tzu
2210      They both may be called deep and profound.
2211      Deeper and more profound,
2212      The door of all subtleties!
2213      =======
2214
2215        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2216      >>>>>>> tao
2217
2218    The '--show-overlap' ('-E') option outputs less information than the
2219 '--show-all' ('-A') option, because it outputs only unmerged changes,
2220 and it never outputs the contents of the second file.  Thus the '-E'
2221 option acts like the '-e' option, except that it brackets the first and
2222 third files from three-way overlapping changes.  Similarly, '-X' acts
2223 like '-x', except it brackets all its (necessarily overlapping) changes.
2224 For example, for the three-way overlapping change above, the '-E' and
2225 '-X' options output the following:
2226
2227      <<<<<<< lao
2228      =======
2229
2230        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2231      >>>>>>> tao
2232
2233    If you are comparing files that have meaningless or uninformative
2234 names, you can use the '--label=LABEL' option to show alternate names in
2235 the '<<<<<<<', '|||||||' and '>>>>>>>' brackets.  This option can be
2236 given up to three times, once for each input file.  Thus 'diff3 -A
2237 --label X --label Y --label Z A B C' acts like 'diff3 -A A B C', except
2238 that the output looks like it came from files named 'X', 'Y' and 'Z'
2239 rather than from files named 'A', 'B' and 'C'.
2240
2241 \1f
2242 File: diffutils.info,  Node: Bypassing ed,  Next: Merging Incomplete Lines,  Prev: Marking Conflicts,  Up: diff3 Merging
2243
2244 8.3 Generating the Merged Output Directly
2245 =========================================
2246
2247 With the '--merge' ('-m') option, 'diff3' outputs the merged file
2248 directly.  This is more efficient than using 'ed' to generate it, and
2249 works even with non-text files that 'ed' would reject.  If you specify
2250 '-m' without an 'ed' script option, '-A' is assumed.
2251
2252    For example, the command 'diff3 -m lao tzu tao' (*note Sample diff3
2253 Input:: for a copy of the input files) would output the following:
2254
2255      <<<<<<< tzu
2256      =======
2257      The Way that can be told of is not the eternal Way;
2258      The name that can be named is not the eternal name.
2259      >>>>>>> tao
2260      The Nameless is the origin of Heaven and Earth;
2261      The Named is the mother of all things.
2262      Therefore let there always be non-being,
2263        so we may see their subtlety,
2264      And let there always be being,
2265        so we may see their result.
2266      The two are the same,
2267      But after they are produced,
2268        they have different names.
2269      <<<<<<< lao
2270      ||||||| tzu
2271      They both may be called deep and profound.
2272      Deeper and more profound,
2273      The door of all subtleties!
2274      =======
2275
2276        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2277      >>>>>>> tao
2278
2279 \1f
2280 File: diffutils.info,  Node: Merging Incomplete Lines,  Next: Saving the Changed File,  Prev: Bypassing ed,  Up: diff3 Merging
2281
2282 8.4 How 'diff3' Merges Incomplete Lines
2283 =======================================
2284
2285 With '-m', incomplete lines (*note Incomplete Lines::) are simply copied
2286 to the output as they are found; if the merged output ends in an
2287 conflict and one of the input files ends in an incomplete line,
2288 succeeding '|||||||', '=======' or '>>>>>>>' brackets appear somewhere
2289 other than the start of a line because they are appended to the
2290 incomplete line.
2291
2292    Without '-m', if an 'ed' script option is specified and an incomplete
2293 line is found, 'diff3' generates a warning and acts as if a newline had
2294 been present.
2295
2296 \1f
2297 File: diffutils.info,  Node: Saving the Changed File,  Prev: Merging Incomplete Lines,  Up: diff3 Merging
2298
2299 8.5 Saving the Changed File
2300 ===========================
2301
2302 Traditional Unix 'diff3' generates an 'ed' script without the trailing
2303 'w' and 'q' commands that save the changes.  System V 'diff3' generates
2304 these extra commands.  GNU 'diff3' normally behaves like traditional
2305 Unix 'diff3', but with the '-i' option it behaves like System V 'diff3'
2306 and appends the 'w' and 'q' commands.
2307
2308    The '-i' option requires one of the 'ed' script options '-AeExX3',
2309 and is incompatible with the merged output option '-m'.
2310
2311 \1f
2312 File: diffutils.info,  Node: Interactive Merging,  Next: Merging with patch,  Prev: diff3 Merging,  Up: Top
2313
2314 9 Interactive Merging with 'sdiff'
2315 **********************************
2316
2317 With 'sdiff', you can merge two files interactively based on a
2318 side-by-side '-y' format comparison (*note Side by Side::).  Use
2319 '--output=FILE' ('-o FILE') to specify where to put the merged text.
2320 *Note Invoking sdiff::, for more details on the options to 'sdiff'.
2321
2322    Another way to merge files interactively is to use the Emacs Lisp
2323 package 'emerge'.  *Note Emerge: (emacs)Emerge, for more information.
2324
2325 * Menu:
2326
2327 * sdiff Option Summary:: Summary of 'sdiff' options.
2328 * Merge Commands::       Merging two files interactively.
2329
2330 \1f
2331 File: diffutils.info,  Node: sdiff Option Summary,  Next: Merge Commands,  Up: Interactive Merging
2332
2333 9.1 Specifying 'diff' Options to 'sdiff'
2334 ========================================
2335
2336 The following 'sdiff' options have the same meaning as for 'diff'.
2337 *Note diff Options::, for the use of these options.
2338
2339      -a -b -d -i -t -v
2340      -B -E -I REGEXP -Z
2341
2342      --expand-tabs
2343      --ignore-blank-lines  --ignore-case
2344      --ignore-matching-lines=REGEXP  --ignore-space-change
2345      --ignore-tab-expansion  --ignore-trailing-space
2346      --left-column  --minimal  --speed-large-files
2347      --strip-trailing-cr  --suppress-common-lines
2348      --tabsize=COLUMNS  --text  --version  --width=COLUMNS
2349
2350    For historical reasons, 'sdiff' has alternate names for some options.
2351 The '-l' option is equivalent to the '--left-column' option, and
2352 similarly '-s' is equivalent to '--suppress-common-lines'.  The meaning
2353 of the 'sdiff' '-w' and '-W' options is interchanged from that of
2354 'diff': with 'sdiff', '-w COLUMNS' is equivalent to '--width=COLUMNS',
2355 and '-W' is equivalent to '--ignore-all-space'.  'sdiff' without the
2356 '-o' option is equivalent to 'diff' with the '--side-by-side' ('-y')
2357 option (*note Side by Side::).
2358
2359 \1f
2360 File: diffutils.info,  Node: Merge Commands,  Prev: sdiff Option Summary,  Up: Interactive Merging
2361
2362 9.2 Merge Commands
2363 ==================
2364
2365 Groups of common lines, with a blank gutter, are copied from the first
2366 file to the output.  After each group of differing lines, 'sdiff'
2367 prompts with '%' and pauses, waiting for one of the following commands.
2368 Follow each command with <RET>.
2369
2370 'e'
2371      Discard both versions.  Invoke a text editor on an empty temporary
2372      file, then copy the resulting file to the output.
2373
2374 'eb'
2375      Concatenate the two versions, edit the result in a temporary file,
2376      then copy the edited result to the output.
2377
2378 'ed'
2379      Like 'eb', except precede each version with a header that shows
2380      what file and lines the version came from.
2381
2382 'el'
2383 'e1'
2384      Edit a copy of the left version, then copy the result to the
2385      output.
2386
2387 'er'
2388 'e2'
2389      Edit a copy of the right version, then copy the result to the
2390      output.
2391
2392 'l'
2393 '1'
2394      Copy the left version to the output.
2395
2396 'q'
2397      Quit.
2398
2399 'r'
2400 '2'
2401      Copy the right version to the output.
2402
2403 's'
2404      Silently copy common lines.
2405
2406 'v'
2407      Verbosely copy common lines.  This is the default.
2408
2409    The text editor invoked is specified by the 'EDITOR' environment
2410 variable if it is set.  The default is system-dependent.
2411
2412 \1f
2413 File: diffutils.info,  Node: Merging with patch,  Next: Making Patches,  Prev: Interactive Merging,  Up: Top
2414
2415 10 Merging with 'patch'
2416 ***********************
2417
2418 'patch' takes comparison output produced by 'diff' and applies the
2419 differences to a copy of the original file, producing a patched version.
2420 With 'patch', you can distribute just the changes to a set of files
2421 instead of distributing the entire file set; your correspondents can
2422 apply 'patch' to update their copy of the files with your changes.
2423 'patch' automatically determines the diff format, skips any leading or
2424 trailing headers, and uses the headers to determine which file to patch.
2425 This lets your correspondents feed a mail message containing a
2426 difference listing directly to 'patch'.
2427
2428    'patch' detects and warns about common problems like forward patches.
2429 It saves any patches that it could not apply.  It can also maintain a
2430 'patchlevel.h' file to ensure that your correspondents apply diffs in
2431 the proper order.
2432
2433    'patch' accepts a series of diffs in its standard input, usually
2434 separated by headers that specify which file to patch.  It applies
2435 'diff' hunks (*note Hunks::) one by one.  If a hunk does not exactly
2436 match the original file, 'patch' uses heuristics to try to patch the
2437 file as well as it can.  If no approximate match can be found, 'patch'
2438 rejects the hunk and skips to the next hunk.  'patch' normally replaces
2439 each file F with its new version, putting reject hunks (if any) into
2440 'F.rej'.
2441
2442    *Note Invoking patch::, for detailed information on the options to
2443 'patch'.
2444
2445 * Menu:
2446
2447 * patch Input::            Selecting the type of 'patch' input.
2448 * Revision Control::       Getting files from RCS, SCCS, etc.
2449 * Imperfect::              Dealing with imperfect patches.
2450 * Creating and Removing::  Creating and removing files with a patch.
2451 * Patching Timestamps::   Updating timestamps on patched files.
2452 * Multiple Patches::       Handling multiple patches in a file.
2453 * patch Directories::      Changing directory and stripping directories.
2454 * Backups::                Whether backup files are made.
2455 * Backup Names::           Backup file names.
2456 * Reject Names::           Reject file names.
2457 * patch Messages::         Messages and questions 'patch' can produce.
2458 * patch and POSIX::        Conformance to the POSIX standard.
2459 * patch and Tradition::    GNU versus traditional 'patch'.
2460
2461 \1f
2462 File: diffutils.info,  Node: patch Input,  Next: Revision Control,  Up: Merging with patch
2463
2464 10.1 Selecting the 'patch' Input Format
2465 =======================================
2466
2467 'patch' normally determines which 'diff' format the patch file uses by
2468 examining its contents.  For patch files that contain particularly
2469 confusing leading text, you might need to use one of the following
2470 options to force 'patch' to interpret the patch file as a certain format
2471 of diff.  The output formats listed here are the only ones that 'patch'
2472 can understand.
2473
2474 '-c'
2475 '--context'
2476      context diff.
2477
2478 '-e'
2479 '--ed'
2480      'ed' script.
2481
2482 '-n'
2483 '--normal'
2484      normal diff.
2485
2486 '-u'
2487 '--unified'
2488      unified diff.
2489
2490 \1f
2491 File: diffutils.info,  Node: Revision Control,  Next: Imperfect,  Prev: patch Input,  Up: Merging with patch
2492
2493 10.2 Revision Control
2494 =====================
2495
2496 If a nonexistent input file is under a revision control system supported
2497 by 'patch', 'patch' normally asks the user whether to get (or check out)
2498 the file from the revision control system.  Patch currently supports
2499 RCS, ClearCase and SCCS. Under RCS and SCCS, 'patch' also asks when the
2500 input file is read-only and matches the default version in the revision
2501 control system.
2502
2503    The '--get=NUM' ('-g NUM') option affects access to files under
2504 supported revision control systems.  If NUM is positive, 'patch' gets
2505 the file without asking the user; if zero, 'patch' neither asks the user
2506 nor gets the file; and if negative, 'patch' asks the user before getting
2507 the file.  The default value of NUM is given by the value of the
2508 'PATCH_GET' environment variable if it is set; if not, the default value
2509 is zero if 'patch' is conforming to POSIX, negative otherwise.  *Note
2510 patch and POSIX::.
2511
2512    The choice of revision control system is unaffected by the
2513 'VERSION_CONTROL' environment variable (*note Backup Names::).
2514
2515 \1f
2516 File: diffutils.info,  Node: Imperfect,  Next: Creating and Removing,  Prev: Revision Control,  Up: Merging with patch
2517
2518 10.3 Applying Imperfect Patches
2519 ===============================
2520
2521 'patch' tries to skip any leading text in the patch file, apply the
2522 diff, and then skip any trailing text.  Thus you can feed a mail message
2523 directly to 'patch', and it should work.  If the entire diff is indented
2524 by a constant amount of white space, 'patch' automatically ignores the
2525 indentation.  If a context diff contains trailing carriage return on
2526 each line, 'patch' automatically ignores the carriage return.  If a
2527 context diff has been encapsulated by prepending '- ' to lines beginning
2528 with '-' as per Internet RFC 934
2529 (ftp://ftp.isi.edu/in-notes/rfc934.txt), 'patch' automatically
2530 unencapsulates the input.
2531
2532    However, certain other types of imperfect input require user
2533 intervention or testing.
2534
2535 * Menu:
2536
2537 * Changed White Space:: When tabs and spaces don't match exactly.
2538 * Reversed Patches::    Applying reversed patches correctly.
2539 * Inexact::             Helping 'patch' find close matches.
2540 * Dry Runs::            Predicting what 'patch' will do.
2541
2542 \1f
2543 File: diffutils.info,  Node: Changed White Space,  Next: Reversed Patches,  Up: Imperfect
2544
2545 10.3.1 Applying Patches with Changed White Space
2546 ------------------------------------------------
2547
2548 Sometimes mailers, editors, or other programs change spaces into tabs,
2549 or vice versa.  If this happens to a patch file or an input file, the
2550 files might look the same, but 'patch' will not be able to match them
2551 properly.  If this problem occurs, use the '-l' or
2552 '--ignore-white-space' option, which makes 'patch' compare blank
2553 characters (i.e. spaces and tabs) loosely so that any nonempty sequence
2554 of blanks in the patch file matches any nonempty sequence of blanks in
2555 the input files.  Non-blank characters must still match exactly.  Each
2556 line of the context must still match a line in the input file.
2557
2558 \1f
2559 File: diffutils.info,  Node: Reversed Patches,  Next: Inexact,  Prev: Changed White Space,  Up: Imperfect
2560
2561 10.3.2 Applying Reversed Patches
2562 --------------------------------
2563
2564 Sometimes people run 'diff' with the new file first instead of second.
2565 This creates a diff that is "reversed".  To apply such patches, give
2566 'patch' the '--reverse' ('-R') option.  'patch' then attempts to swap
2567 each hunk around before applying it.  Rejects come out in the swapped
2568 format.
2569
2570    Often 'patch' can guess that the patch is reversed.  If the first
2571 hunk of a patch fails, 'patch' reverses the hunk to see if it can apply
2572 it that way.  If it can, 'patch' asks you if you want to have the '-R'
2573 option set; if it can't, 'patch' continues to apply the patch normally.
2574 This method cannot detect a reversed patch if it is a normal diff and
2575 the first command is an append (which should have been a delete) since
2576 appends always succeed, because a null context matches anywhere.  But
2577 most patches add or change lines rather than delete them, so most
2578 reversed normal diffs begin with a delete, which fails, and 'patch'
2579 notices.
2580
2581    If you apply a patch that you have already applied, 'patch' thinks it
2582 is a reversed patch and offers to un-apply the patch.  This could be
2583 construed as a feature.  If you did this inadvertently and you don't
2584 want to un-apply the patch, just answer 'n' to this offer and to the
2585 subsequent "apply anyway" question--or type 'C-c' to kill the 'patch'
2586 process.
2587
2588 \1f
2589 File: diffutils.info,  Node: Inexact,  Next: Dry Runs,  Prev: Reversed Patches,  Up: Imperfect
2590
2591 10.3.3 Helping 'patch' Find Inexact Matches
2592 -------------------------------------------
2593
2594 For context diffs, and to a lesser extent normal diffs, 'patch' can
2595 detect when the line numbers mentioned in the patch are incorrect, and
2596 it attempts to find the correct place to apply each hunk of the patch.
2597 As a first guess, it takes the line number mentioned in the hunk, plus
2598 or minus any offset used in applying the previous hunk.  If that is not
2599 the correct place, 'patch' scans both forward and backward for a set of
2600 lines matching the context given in the hunk.
2601
2602    First 'patch' looks for a place where all lines of the context match.
2603 If it cannot find such a place, and it is reading a context or unified
2604 diff, and the maximum fuzz factor is set to 1 or more, then 'patch'
2605 makes another scan, ignoring the first and last line of context.  If
2606 that fails, and the maximum fuzz factor is set to 2 or more, it makes
2607 another scan, ignoring the first two and last two lines of context are
2608 ignored.  It continues similarly if the maximum fuzz factor is larger.
2609
2610    The '--fuzz=LINES' ('-F LINES') option sets the maximum fuzz factor
2611 to LINES.  This option only applies to context and unified diffs; it
2612 ignores up to LINES lines while looking for the place to install a hunk.
2613 Note that a larger fuzz factor increases the odds of making a faulty
2614 patch.  The default fuzz factor is 2; there is no point to setting it to
2615 more than the number of lines of context in the diff, ordinarily 3.
2616
2617    If 'patch' cannot find a place to install a hunk of the patch, it
2618 writes the hunk out to a reject file (*note Reject Names::, for
2619 information on how reject files are named).  It writes out rejected
2620 hunks in context format no matter what form the input patch is in.  If
2621 the input is a normal or 'ed' diff, many of the contexts are simply
2622 null.  The line numbers on the hunks in the reject file may be different
2623 from those in the patch file: they show the approximate location where
2624 'patch' thinks the failed hunks belong in the new file rather than in
2625 the old one.
2626
2627    If the '--verbose' option is given, then as it completes each hunk
2628 'patch' tells you whether the hunk succeeded or failed, and if it
2629 failed, on which line (in the new file) 'patch' thinks the hunk should
2630 go.  If this is different from the line number specified in the diff, it
2631 tells you the offset.  A single large offset _may_ indicate that 'patch'
2632 installed a hunk in the wrong place.  'patch' also tells you if it used
2633 a fuzz factor to make the match, in which case you should also be
2634 slightly suspicious.
2635
2636    'patch' cannot tell if the line numbers are off in an 'ed' script,
2637 and can only detect wrong line numbers in a normal diff when it finds a
2638 change or delete command.  It may have the same problem with a context
2639 diff using a fuzz factor equal to or greater than the number of lines of
2640 context shown in the diff (typically 3).  In these cases, you should
2641 probably look at a context diff between your original and patched input
2642 files to see if the changes make sense.  Compiling without errors is a
2643 pretty good indication that the patch worked, but not a guarantee.
2644
2645    A patch against an empty file applies to a nonexistent file, and vice
2646 versa.  *Note Creating and Removing::.
2647
2648    'patch' usually produces the correct results, even when it must make
2649 many guesses.  However, the results are guaranteed only when the patch
2650 is applied to an exact copy of the file that the patch was generated
2651 from.
2652
2653 \1f
2654 File: diffutils.info,  Node: Dry Runs,  Prev: Inexact,  Up: Imperfect
2655
2656 10.3.4 Predicting what 'patch' will do
2657 --------------------------------------
2658
2659 It may not be obvious in advance what 'patch' will do with a complicated
2660 or poorly formatted patch.  If you are concerned that the input might
2661 cause 'patch' to modify the wrong files, you can use the '--dry-run'
2662 option, which causes 'patch' to print the results of applying patches
2663 without actually changing any files.  You can then inspect the
2664 diagnostics generated by the dry run to see whether 'patch' will modify
2665 the files that you expect.  If the patch does not do what you want, you
2666 can modify the patch (or the other options to 'patch') and try another
2667 dry run.  Once you are satisfied with the proposed patch you can apply
2668 it by invoking 'patch' as before, but this time without the '--dry-run'
2669 option.
2670
2671 \1f
2672 File: diffutils.info,  Node: Creating and Removing,  Next: Patching Timestamps,  Prev: Imperfect,  Up: Merging with patch
2673
2674 10.4 Creating and Removing Files
2675 ================================
2676
2677 Sometimes when comparing two directories, a file may exist in one
2678 directory but not the other.  If you give 'diff' the '--new-file' ('-N')
2679 option, or if you supply an old or new file that is named '/dev/null' or
2680 is empty and is dated the Epoch (1970-01-01 00:00:00 UTC), 'diff'
2681 outputs a patch that adds or deletes the contents of this file.  When
2682 given such a patch, 'patch' normally creates a new file or removes the
2683 old file.  However, when conforming to POSIX (*note patch and POSIX::),
2684 'patch' does not remove the old file, but leaves it empty.  The
2685 '--remove-empty-files' ('-E') option causes 'patch' to remove output
2686 files that are empty after applying a patch, even if the patch does not
2687 appear to be one that removed the file.
2688
2689    If the patch appears to create a file that already exists, 'patch'
2690 asks for confirmation before applying the patch.
2691
2692 \1f
2693 File: diffutils.info,  Node: Patching Timestamps,  Next: Multiple Patches,  Prev: Creating and Removing,  Up: Merging with patch
2694
2695 10.5 Updating Timestamps on Patched Files
2696 =========================================
2697
2698 When 'patch' updates a file, it normally sets the file's last-modified
2699 timestamp to the current time of day.  If you are using 'patch' to track
2700 a software distribution, this can cause 'make' to incorrectly conclude
2701 that a patched file is out of date.  For example, if 'syntax.c' depends
2702 on 'syntax.y', and 'patch' updates 'syntax.c' and then 'syntax.y', then
2703 'syntax.c' will normally appear to be out of date with respect to
2704 'syntax.y' even though its contents are actually up to date.
2705
2706    The '--set-utc' ('-Z') option causes 'patch' to set a patched file's
2707 modification and access times to the timestamps given in context diff
2708 headers.  If the context diff headers do not specify a time zone, they
2709 are assumed to use Coordinated Universal Time (UTC, often known as GMT).
2710
2711    The '--set-time' ('-T') option acts like '-Z' or '--set-utc', except
2712 that it assumes that the context diff headers' timestamps use local time
2713 instead of UTC. This option is not recommended, because patches using
2714 local time cannot easily be used by people in other time zones, and
2715 because local timestamps are ambiguous when local clocks move backwards
2716 during daylight-saving time adjustments.  If the context diff headers
2717 specify a time zone, this option is equivalent to '--set-utc' ('-Z').
2718
2719    'patch' normally refrains from setting a file's timestamps if the
2720 file's original last-modified timestamp does not match the time given in
2721 the diff header, of if the file's contents do not exactly match the
2722 patch.  However, if the '--force' ('-f') option is given, the file's
2723 timestamps are set regardless.
2724
2725    Due to the limitations of the current 'diff' format, 'patch' cannot
2726 update the times of files whose contents have not changed.  Also, if you
2727 set file timestamps to values other than the current time of day, you
2728 should also remove (e.g., with 'make clean') all files that depend on
2729 the patched files, so that later invocations of 'make' do not get
2730 confused by the patched files' times.
2731
2732 \1f
2733 File: diffutils.info,  Node: Multiple Patches,  Next: patch Directories,  Prev: Patching Timestamps,  Up: Merging with patch
2734
2735 10.6 Multiple Patches in a File
2736 ===============================
2737
2738 If the patch file contains more than one patch, and if you do not
2739 specify an input file on the command line, 'patch' tries to apply each
2740 patch as if they came from separate patch files.  This means that it
2741 determines the name of the file to patch for each patch, and that it
2742 examines the leading text before each patch for file names and
2743 prerequisite revision level (*note Making Patches::, for more on that
2744 topic).
2745
2746    'patch' uses the following rules to intuit a file name from the
2747 leading text before a patch.  First, 'patch' takes an ordered list of
2748 candidate file names as follows:
2749
2750    * If the header is that of a context diff, 'patch' takes the old and
2751      new file names in the header.  A name is ignored if it does not
2752      have enough slashes to satisfy the '-pNUM' or '--strip=NUM' option.
2753      The name '/dev/null' is also ignored.
2754
2755    * If there is an 'Index:' line in the leading garbage and if either
2756      the old and new names are both absent or if 'patch' is conforming
2757      to POSIX, 'patch' takes the name in the 'Index:' line.
2758
2759    * For the purpose of the following rules, the candidate file names
2760      are considered to be in the order (old, new, index), regardless of
2761      the order that they appear in the header.
2762
2763 Then 'patch' selects a file name from the candidate list as follows:
2764
2765    * If some of the named files exist, 'patch' selects the first name if
2766      conforming to POSIX, and the best name otherwise.
2767
2768    * If 'patch' is not ignoring RCS, ClearCase, and SCCS (*note Revision
2769      Control::), and no named files exist but an RCS, ClearCase, or SCCS
2770      master is found, 'patch' selects the first named file with an RCS,
2771      ClearCase, or SCCS master.
2772
2773    * If no named files exist, no RCS, ClearCase, or SCCS master was
2774      found, some names are given, 'patch' is not conforming to POSIX,
2775      and the patch appears to create a file, 'patch' selects the best
2776      name requiring the creation of the fewest directories.
2777
2778    * If no file name results from the above heuristics, you are asked
2779      for the name of the file to patch, and 'patch' selects that name.
2780
2781    To determine the "best" of a nonempty list of file names, 'patch'
2782 first takes all the names with the fewest path name components; of
2783 those, it then takes all the names with the shortest basename; of those,
2784 it then takes all the shortest names; finally, it takes the first
2785 remaining name.
2786
2787    *Note patch and POSIX::, to see whether 'patch' is conforming to
2788 POSIX.
2789
2790 \1f
2791 File: diffutils.info,  Node: patch Directories,  Next: Backups,  Prev: Multiple Patches,  Up: Merging with patch
2792
2793 10.7 Applying Patches in Other Directories
2794 ==========================================
2795
2796 The '--directory=DIRECTORY' ('-d DIRECTORY') option to 'patch' makes
2797 directory DIRECTORY the current directory for interpreting both file
2798 names in the patch file, and file names given as arguments to other
2799 options (such as '-B' and '-o').  For example, while in a mail reading
2800 program, you can patch a file in the '/usr/src/emacs' directory directly
2801 from a message containing the patch like this:
2802
2803      | patch -d /usr/src/emacs
2804
2805    Sometimes the file names given in a patch contain leading
2806 directories, but you keep your files in a directory different from the
2807 one given in the patch.  In those cases, you can use the
2808 '--strip=NUMBER' ('-pNUMBER') option to set the file name strip count to
2809 NUMBER.  The strip count tells 'patch' how many slashes, along with the
2810 directory names between them, to strip from the front of file names.  A
2811 sequence of one or more adjacent slashes is counted as a single slash.
2812 By default, 'patch' strips off all leading directories, leaving just the
2813 base file names.
2814
2815    For example, suppose the file name in the patch file is
2816 '/gnu/src/emacs/etc/NEWS'.  Using '-p0' gives the entire file name
2817 unmodified, '-p1' gives 'gnu/src/emacs/etc/NEWS' (no leading slash),
2818 '-p4' gives 'etc/NEWS', and not specifying '-p' at all gives 'NEWS'.
2819
2820    'patch' looks for each file (after any slashes have been stripped) in
2821 the current directory, or if you used the '-d DIRECTORY' option, in that
2822 directory.
2823
2824 \1f
2825 File: diffutils.info,  Node: Backups,  Next: Backup Names,  Prev: patch Directories,  Up: Merging with patch
2826
2827 10.8 Backup Files
2828 =================
2829
2830 Normally, 'patch' creates a backup file if the patch does not exactly
2831 match the original input file, because in that case the original data
2832 might not be recovered if you undo the patch with 'patch -R' (*note
2833 Reversed Patches::).  However, when conforming to POSIX, 'patch' does
2834 not create backup files by default.  *Note patch and POSIX::.
2835
2836    The '--backup' ('-b') option causes 'patch' to make a backup file
2837 regardless of whether the patch matches the original input.  The
2838 '--backup-if-mismatch' option causes 'patch' to create backup files for
2839 mismatches files; this is the default when not conforming to POSIX. The
2840 '--no-backup-if-mismatch' option causes 'patch' to not create backup
2841 files, even for mismatched patches; this is the default when conforming
2842 to POSIX.
2843
2844    When backing up a file that does not exist, an empty, unreadable
2845 backup file is created as a placeholder to represent the nonexistent
2846 file.
2847
2848 \1f
2849 File: diffutils.info,  Node: Backup Names,  Next: Reject Names,  Prev: Backups,  Up: Merging with patch
2850
2851 10.9 Backup File Names
2852 ======================
2853
2854 Normally, 'patch' renames an original input file into a backup file by
2855 appending to its name the extension '.orig', or '~' if using '.orig'
2856 would make the backup file name too long.(1)  The '-z BACKUP-SUFFIX' or
2857 '--suffix=BACKUP-SUFFIX' option causes 'patch' to use BACKUP-SUFFIX as
2858 the backup extension instead.
2859
2860    Alternately, you can specify the extension for backup files with the
2861 'SIMPLE_BACKUP_SUFFIX' environment variable, which the options override.
2862
2863    'patch' can also create numbered backup files the way GNU Emacs does.
2864 With this method, instead of having a single backup of each file,
2865 'patch' makes a new backup file name each time it patches a file.  For
2866 example, the backups of a file named 'sink' would be called,
2867 successively, 'sink.~1~', 'sink.~2~', 'sink.~3~', etc.
2868
2869    The '-V BACKUP-STYLE' or '--version-control=BACKUP-STYLE' option
2870 takes as an argument a method for creating backup file names.  You can
2871 alternately control the type of backups that 'patch' makes with the
2872 'PATCH_VERSION_CONTROL' environment variable, which the '-V' option
2873 overrides.  If 'PATCH_VERSION_CONTROL' is not set, the 'VERSION_CONTROL'
2874 environment variable is used instead.  Please note that these options
2875 and variables control backup file names; they do not affect the choice
2876 of revision control system (*note Revision Control::).
2877
2878    The values of these environment variables and the argument to the
2879 '-V' option are like the GNU Emacs 'version-control' variable (*note
2880 (emacs)Backup Names::, for more information on backup versions in
2881 Emacs).  They also recognize synonyms that are more descriptive.  The
2882 valid values are listed below; unique abbreviations are acceptable.
2883
2884 't'
2885 'numbered'
2886      Always make numbered backups.
2887
2888 'nil'
2889 'existing'
2890      Make numbered backups of files that already have them, simple
2891      backups of the others.  This is the default.
2892
2893 'never'
2894 'simple'
2895      Always make simple backups.
2896
2897    You can also tell 'patch' to prepend a prefix, such as a directory
2898 name, to produce backup file names.  The '--prefix=PREFIX' ('-B PREFIX')
2899 option makes backup files by prepending PREFIX to them.  The
2900 '--basename-prefix=PREFIX' ('-Y PREFIX') prepends PREFIX to the last
2901 file name component of backup file names instead; for example, '-Y ~'
2902 causes the backup name for 'dir/file.c' to be 'dir/~file.c'.  If you use
2903 either of these prefix options, the suffix-based options are ignored.
2904
2905    If you specify the output file with the '-o' option, that file is the
2906 one that is backed up, not the input file.
2907
2908    Options that affect the names of backup files do not affect whether
2909 backups are made.  For example, if you specify the
2910 '--no-backup-if-mismatch' option, none of the options described in this
2911 section have any affect, because no backups are made.
2912
2913    ---------- Footnotes ----------
2914
2915    (1) A coding error in GNU 'patch' version 2.5.4 causes it to always
2916 use '~', but this should be fixed in the next release.
2917
2918 \1f
2919 File: diffutils.info,  Node: Reject Names,  Next: patch Messages,  Prev: Backup Names,  Up: Merging with patch
2920
2921 10.10 Reject File Names
2922 =======================
2923
2924 The names for reject files (files containing patches that 'patch' could
2925 not find a place to apply) are normally the name of the output file with
2926 '.rej' appended (or '#' if using '.rej' would make the backup file name
2927 too long).
2928
2929    Alternatively, you can tell 'patch' to place all of the rejected
2930 patches in a single file.  The '-r REJECT-FILE' or
2931 '--reject-file=REJECT-FILE' option uses REJECT-FILE as the reject file
2932 name.
2933
2934 \1f
2935 File: diffutils.info,  Node: patch Messages,  Next: patch and POSIX,  Prev: Reject Names,  Up: Merging with patch
2936
2937 10.11 Messages and Questions from 'patch'
2938 =========================================
2939
2940 'patch' can produce a variety of messages, especially if it has trouble
2941 decoding its input.  In a few situations where it's not sure how to
2942 proceed, 'patch' normally prompts you for more information from the
2943 keyboard.  There are options to produce more or fewer messages, to have
2944 it not ask for keyboard input, and to affect the way that file names are
2945 quoted in messages.
2946
2947 * Menu:
2948
2949 * More or Fewer Messages::    Controlling the verbosity of 'patch'.
2950 * patch and Keyboard Input::  Inhibiting keyboard input.
2951 * patch Quoting Style::       Quoting file names in diagnostics.
2952
2953    'patch' exits with status 0 if all hunks are applied successfully, 1
2954 if some hunks cannot be applied, and 2 if there is more serious trouble.
2955 When applying a set of patches in a loop, you should check the exit
2956 status, so you don't apply a later patch to a partially patched file.
2957
2958 \1f
2959 File: diffutils.info,  Node: More or Fewer Messages,  Next: patch and Keyboard Input,  Up: patch Messages
2960
2961 10.11.1 Controlling the Verbosity of 'patch'
2962 --------------------------------------------
2963
2964 You can cause 'patch' to produce more messages by using the '--verbose'
2965 option.  For example, when you give this option, the message 'Hmm...'
2966 indicates that 'patch' is reading text in the patch file, attempting to
2967 determine whether there is a patch in that text, and if so, what kind of
2968 patch it is.
2969
2970    You can inhibit all terminal output from 'patch', unless an error
2971 occurs, by using the '-s', '--quiet', or '--silent' option.
2972
2973 \1f
2974 File: diffutils.info,  Node: patch and Keyboard Input,  Next: patch Quoting Style,  Prev: More or Fewer Messages,  Up: patch Messages
2975
2976 10.11.2 Inhibiting Keyboard Input
2977 ---------------------------------
2978
2979 There are two ways you can prevent 'patch' from asking you any
2980 questions.  The '--force' ('-f') option assumes that you know what you
2981 are doing.  It causes 'patch' to do the following:
2982
2983    * Skip patches that do not contain file names in their headers.
2984
2985    * Patch files even though they have the wrong version for the
2986      'Prereq:' line in the patch;
2987
2988    * Assume that patches are not reversed even if they look like they
2989      are.
2990
2991 The '--batch' ('-t') option is similar to '-f', in that it suppresses
2992 questions, but it makes somewhat different assumptions:
2993
2994    * Skip patches that do not contain file names in their headers (the
2995      same as '-f').
2996
2997    * Skip patches for which the file has the wrong version for the
2998      'Prereq:' line in the patch;
2999
3000    * Assume that patches are reversed if they look like they are.
3001
3002 \1f
3003 File: diffutils.info,  Node: patch Quoting Style,  Prev: patch and Keyboard Input,  Up: patch Messages
3004
3005 10.11.3 'patch' Quoting Style
3006 -----------------------------
3007
3008 When 'patch' outputs a file name in a diagnostic message, it can format
3009 the name in any of several ways.  This can be useful to output file
3010 names unambiguously, even if they contain punctuation or special
3011 characters like newlines.  The '--quoting-style=WORD' option controls
3012 how names are output.  The WORD should be one of the following:
3013
3014 'literal'
3015      Output names as-is.
3016 'shell'
3017      Quote names for the shell if they contain shell metacharacters or
3018      would cause ambiguous output.
3019 'shell-always'
3020      Quote names for the shell, even if they would normally not require
3021      quoting.
3022 'c'
3023      Quote names as for a C language string.
3024 'escape'
3025      Quote as with 'c' except omit the surrounding double-quote
3026      characters.
3027
3028    You can specify the default value of the '--quoting-style' option
3029 with the environment variable 'QUOTING_STYLE'.  If that environment
3030 variable is not set, the default value is 'shell', but this default may
3031 change in a future version of 'patch'.
3032
3033 \1f
3034 File: diffutils.info,  Node: patch and POSIX,  Next: patch and Tradition,  Prev: patch Messages,  Up: Merging with patch
3035
3036 10.12 'patch' and the POSIX Standard
3037 ====================================
3038
3039 If you specify the '--posix' option, or set the 'POSIXLY_CORRECT'
3040 environment variable, 'patch' conforms more strictly to the POSIX
3041 standard, as follows:
3042
3043    * Take the first existing file from the list (old, new, index) when
3044      intuiting file names from diff headers.  *Note Multiple Patches::.
3045
3046    * Do not remove files that are removed by a diff.  *Note Creating and
3047      Removing::.
3048
3049    * Do not ask whether to get files from RCS, ClearCase, or SCCS. *Note
3050      Revision Control::.
3051
3052    * Require that all options precede the files in the command line.
3053
3054    * Do not backup files, even when there is a mismatch.  *Note
3055      Backups::.
3056
3057 \1f
3058 File: diffutils.info,  Node: patch and Tradition,  Prev: patch and POSIX,  Up: Merging with patch
3059
3060 10.13 GNU 'patch' and Traditional 'patch'
3061 =========================================
3062
3063 The current version of GNU 'patch' normally follows the POSIX standard.
3064 *Note patch and POSIX::, for the few exceptions to this general rule.
3065
3066    Unfortunately, POSIX redefined the behavior of 'patch' in several
3067 important ways.  You should be aware of the following differences if you
3068 must interoperate with traditional 'patch', or with GNU 'patch' version
3069 2.1 and earlier.
3070
3071    * In traditional 'patch', the '-p' option's operand was optional, and
3072      a bare '-p' was equivalent to '-p0'.  The '-p' option now requires
3073      an operand, and '-p 0' is now equivalent to '-p0'.  For maximum
3074      compatibility, use options like '-p0' and '-p1'.
3075
3076      Also, traditional 'patch' simply counted slashes when stripping
3077      path prefixes; 'patch' now counts pathname components.  That is, a
3078      sequence of one or more adjacent slashes now counts as a single
3079      slash.  For maximum portability, avoid sending patches containing
3080      '//' in file names.
3081
3082    * In traditional 'patch', backups were enabled by default.  This
3083      behavior is now enabled with the '--backup' ('-b') option.
3084
3085      Conversely, in POSIX 'patch', backups are never made, even when
3086      there is a mismatch.  In GNU 'patch', this behavior is enabled with
3087      the '--no-backup-if-mismatch' option, or by conforming to POSIX.
3088
3089      The '-b SUFFIX' option of traditional 'patch' is equivalent to the
3090      '-b -z SUFFIX' options of GNU 'patch'.
3091
3092    * Traditional 'patch' used a complicated (and incompletely
3093      documented) method to intuit the name of the file to be patched
3094      from the patch header.  This method did not conform to POSIX, and
3095      had a few gotchas.  Now 'patch' uses a different, equally
3096      complicated (but better documented) method that is optionally
3097      POSIX-conforming; we hope it has fewer gotchas.  The two methods
3098      are compatible if the file names in the context diff header and the
3099      'Index:' line are all identical after prefix-stripping.  Your patch
3100      is normally compatible if each header's file names all contain the
3101      same number of slashes.
3102
3103    * When traditional 'patch' asked the user a question, it sent the
3104      question to standard error and looked for an answer from the first
3105      file in the following list that was a terminal: standard error,
3106      standard output, '/dev/tty', and standard input.  Now 'patch' sends
3107      questions to standard output and gets answers from '/dev/tty'.
3108      Defaults for some answers have been changed so that 'patch' never
3109      goes into an infinite loop when using default answers.
3110
3111    * Traditional 'patch' exited with a status value that counted the
3112      number of bad hunks, or with status 1 if there was real trouble.
3113      Now 'patch' exits with status 1 if some hunks failed, or with 2 if
3114      there was real trouble.
3115
3116    * Limit yourself to the following options when sending instructions
3117      meant to be executed by anyone running GNU 'patch', traditional
3118      'patch', or a 'patch' that conforms to POSIX. Spaces are
3119      significant in the following list, and operands are required.
3120
3121           -c
3122           -d DIR
3123           -D DEFINE
3124           -e
3125           -l
3126           -n
3127           -N
3128           -o OUTFILE
3129           -pNUM
3130           -R
3131           -r REJECTFILE
3132
3133 \1f
3134 File: diffutils.info,  Node: Making Patches,  Next: Invoking cmp,  Prev: Merging with patch,  Up: Top
3135
3136 11 Tips for Making and Using Patches
3137 ************************************
3138
3139 Use some common sense when making and using patches.  For example, when
3140 sending bug fixes to a program's maintainer, send several small patches,
3141 one per independent subject, instead of one large, harder-to-digest
3142 patch that covers all the subjects.
3143
3144    Here are some other things you should keep in mind if you are going
3145 to distribute patches for updating a software package.
3146
3147 * Menu:
3148
3149 * Tips for Patch Producers::    Advice for making patches.
3150 * Tips for Patch Consumers::    Advice for using patches.
3151 * Avoiding Common Mistakes::    Avoiding common mistakes when using 'patch'.
3152 * Generating Smaller Patches::  How to generate smaller patches.
3153
3154 \1f
3155 File: diffutils.info,  Node: Tips for Patch Producers,  Next: Tips for Patch Consumers,  Up: Making Patches
3156
3157 11.1 Tips for Patch Producers
3158 =============================
3159
3160 To create a patch that changes an older version of a package into a
3161 newer version, first make a copy of the older and newer versions in
3162 adjacent subdirectories.  It is common to do that by unpacking 'tar'
3163 archives of the two versions.
3164
3165    To generate the patch, use the command 'diff -Naur OLD NEW' where OLD
3166 and NEW identify the old and new directories.  The names OLD and NEW
3167 should not contain any slashes.  The '-N' option lets the patch create
3168 and remove files; '-a' lets the patch update non-text files; '-u'
3169 generates useful timestamps and enough context; and '-r' lets the patch
3170 update subdirectories.  Here is an example command, using Bourne shell
3171 syntax:
3172
3173      diff -Naur gcc-3.0.3 gcc-3.0.4
3174
3175    Tell your recipients how to apply the patches.  This should include
3176 which working directory to use, and which 'patch' options to use; the
3177 option '-p1' is recommended.  Test your procedure by pretending to be a
3178 recipient and applying your patches to a copy of the original files.
3179
3180    *Note Avoiding Common Mistakes::, for how to avoid common mistakes
3181 when generating a patch.
3182
3183 \1f
3184 File: diffutils.info,  Node: Tips for Patch Consumers,  Next: Avoiding Common Mistakes,  Prev: Tips for Patch Producers,  Up: Making Patches
3185
3186 11.2 Tips for Patch Consumers
3187 =============================
3188
3189 A patch producer should tell recipients how to apply the patches, so the
3190 first rule of thumb for a patch consumer is to follow the instructions
3191 supplied with the patch.
3192
3193    GNU 'diff' can analyze files with arbitrarily long lines and files
3194 that end in incomplete lines.  However, older versions of 'patch' cannot
3195 patch such files.  If you are having trouble applying such patches, try
3196 upgrading to a recent version of GNU 'patch'.
3197
3198 \1f
3199 File: diffutils.info,  Node: Avoiding Common Mistakes,  Next: Generating Smaller Patches,  Prev: Tips for Patch Consumers,  Up: Making Patches
3200
3201 11.3 Avoiding Common Mistakes
3202 =============================
3203
3204 When producing a patch for multiple files, apply 'diff' to directories
3205 whose names do not have slashes.  This reduces confusion when the patch
3206 consumer specifies the '-pNUMBER' option, since this option can have
3207 surprising results when the old and new file names have different
3208 numbers of slashes.  For example, do not send a patch with a header that
3209 looks like this:
3210
3211      diff -Naur v2.0.29/prog/README prog/README
3212      --- v2.0.29/prog/README    2002-03-10 23:30:39.942229878 -0800
3213      +++ prog/README    2002-03-17 20:49:32.442260588 -0800
3214
3215 because the two file names have different numbers of slashes, and
3216 different versions of 'patch' interpret the file names differently.  To
3217 avoid confusion, send output that looks like this instead:
3218
3219      diff -Naur v2.0.29/prog/README v2.0.30/prog/README
3220      --- v2.0.29/prog/README    2002-03-10 23:30:39.942229878 -0800
3221      +++ v2.0.30/prog/README    2002-03-17 20:49:32.442260588 -0800
3222
3223    Make sure you have specified the file names correctly, either in a
3224 context diff header or with an 'Index:' line.  Take care to not send out
3225 reversed patches, since these make people wonder whether they have
3226 already applied the patch.
3227
3228    Avoid sending patches that compare backup file names like
3229 'README.orig' or 'README~', since this might confuse 'patch' into
3230 patching a backup file instead of the real file.  Instead, send patches
3231 that compare the same base file names in different directories, e.g.
3232 'old/README' and 'new/README'.
3233
3234    To save people from partially applying a patch before other patches
3235 that should have gone before it, you can make the first patch in the
3236 patch file update a file with a name like 'patchlevel.h' or 'version.c',
3237 which contains a patch level or version number.  If the input file
3238 contains the wrong version number, 'patch' will complain immediately.
3239
3240    An even clearer way to prevent this problem is to put a 'Prereq:'
3241 line before the patch.  If the leading text in the patch file contains a
3242 line that starts with 'Prereq:', 'patch' takes the next word from that
3243 line (normally a version number) and checks whether the next input file
3244 contains that word, preceded and followed by either white space or a
3245 newline.  If not, 'patch' prompts you for confirmation before
3246 proceeding.  This makes it difficult to accidentally apply patches in
3247 the wrong order.
3248
3249 \1f
3250 File: diffutils.info,  Node: Generating Smaller Patches,  Prev: Avoiding Common Mistakes,  Up: Making Patches
3251
3252 11.4 Generating Smaller Patches
3253 ===============================
3254
3255 The simplest way to generate a patch is to use 'diff -Naur' (*note Tips
3256 for Patch Producers::), but you might be able to reduce the size of the
3257 patch by renaming or removing some files before making the patch.  If
3258 the older version of the package contains any files that the newer
3259 version does not, or if any files have been renamed between the two
3260 versions, make a list of 'rm' and 'mv' commands for the user to execute
3261 in the old version directory before applying the patch.  Then run those
3262 commands yourself in the scratch directory.
3263
3264    If there are any files that you don't need to include in the patch
3265 because they can easily be rebuilt from other files (for example, 'TAGS'
3266 and output from 'yacc' and 'makeinfo'), exclude them from the patch by
3267 giving 'diff' the '-x PATTERN' option (*note Comparing Directories::).
3268 If you want your patch to modify a derived file because your recipients
3269 lack tools to build it, make sure that the patch for the derived file
3270 follows any patches for files that it depends on, so that the
3271 recipients' timestamps will not confuse 'make'.
3272
3273    Now you can create the patch using 'diff -Naur'.  Make sure to
3274 specify the scratch directory first and the newer directory second.
3275
3276    Add to the top of the patch a note telling the user any 'rm' and 'mv'
3277 commands to run before applying the patch.  Then you can remove the
3278 scratch directory.
3279
3280    You can also shrink the patch size by using fewer lines of context,
3281 but bear in mind that 'patch' typically needs at least two lines for
3282 proper operation when patches do not exactly match the input files.
3283
3284 \1f
3285 File: diffutils.info,  Node: Invoking cmp,  Next: Invoking diff,  Prev: Making Patches,  Up: Top
3286
3287 12 Invoking 'cmp'
3288 *****************
3289
3290 The 'cmp' command compares two files, and if they differ, tells the
3291 first byte and line number where they differ or reports that one file is
3292 a prefix of the other.  Bytes and lines are numbered starting with 1.
3293 The arguments of 'cmp' are as follows:
3294
3295      cmp OPTIONS... FROM-FILE [TO-FILE [FROM-SKIP [TO-SKIP]]]
3296
3297    The file name '-' is always the standard input.  'cmp' also uses the
3298 standard input if one file name is omitted.  The FROM-SKIP and TO-SKIP
3299 operands specify how many bytes to ignore at the start of each file;
3300 they are equivalent to the '--ignore-initial=FROM-SKIP:TO-SKIP' option.
3301
3302    By default, 'cmp' outputs nothing if the two files have the same
3303 contents.  If the two files have bytes that differ, 'cmp' reports the
3304 location of the first difference to standard output:
3305
3306      FROM-FILE TO-FILE differ: char BYTE-NUMBER, line LINE-NUMBER
3307
3308 If one file is a prefix of the other, 'cmp' reports the shorter file's
3309 name to standard error, followed by a blank and extra information about
3310 the shorter file:
3311
3312      cmp: EOF on SHORTER-FILE EXTRA-INFO
3313
3314    The message formats can differ outside the POSIX locale.  POSIX
3315 allows but does not require the EOF diagnostic's file name to be
3316 followed by a blank and additional information.
3317
3318    An exit status of 0 means no differences were found, 1 means some
3319 differences were found, and 2 means trouble.
3320
3321 * Menu:
3322
3323 * cmp Options:: Summary of options to 'cmp'.
3324
3325 \1f
3326 File: diffutils.info,  Node: cmp Options,  Up: Invoking cmp
3327
3328 12.1 Options to 'cmp'
3329 =====================
3330
3331 Below is a summary of all of the options that GNU 'cmp' accepts.  Most
3332 options have two equivalent names, one of which is a single letter
3333 preceded by '-', and the other of which is a long name preceded by '--'.
3334 Multiple single letter options (unless they take an argument) can be
3335 combined into a single command line word: '-bl' is equivalent to '-b
3336 -l'.
3337
3338 '-b'
3339 '--print-bytes'
3340      Print the differing bytes.  Display control bytes as a '^' followed
3341      by a letter of the alphabet and precede bytes that have the high
3342      bit set with 'M-' (which stands for "meta").
3343
3344 '--help'
3345      Output a summary of usage and then exit.
3346
3347 '-i SKIP'
3348 '--ignore-initial=SKIP'
3349      Ignore any differences in the first SKIP bytes of the input files.
3350      Treat files with fewer than SKIP bytes as if they are empty.  If
3351      SKIP is of the form 'FROM-SKIP:TO-SKIP', skip the first FROM-SKIP
3352      bytes of the first input file and the first TO-SKIP bytes of the
3353      second.
3354
3355 '-l'
3356 '--verbose'
3357      Output the (decimal) byte numbers and (octal) values of all
3358      differing bytes, instead of the default standard output.  Each
3359      output line contains a differing byte's number relative to the
3360      start of the input, followed by the differing byte values.  Byte
3361      numbers start at 1.  Also, output the EOF message if one file is
3362      shorter than the other.
3363
3364 '-n COUNT'
3365 '--bytes=COUNT'
3366      Compare at most COUNT input bytes.
3367
3368 '-s'
3369 '--quiet'
3370 '--silent'
3371      Do not print anything; only return an exit status indicating
3372      whether the files differ.
3373
3374 '-v'
3375 '--version'
3376      Output version information and then exit.
3377
3378    In the above table, operands that are byte counts are normally
3379 decimal, but may be preceded by '0' for octal and '0x' for hexadecimal.
3380
3381    A byte count can be followed by a suffix to specify a multiple of
3382 that count; in this case an omitted integer is understood to be 1.  A
3383 bare size letter, or one followed by 'iB', specifies a multiple using
3384 powers of 1024.  A size letter followed by 'B' specifies powers of 1000
3385 instead.  For example, '-n 4M' and '-n 4MiB' are equivalent to '-n
3386 4194304', whereas '-n 4MB' is equivalent to '-n 4000000'.  This notation
3387 is upward compatible with the SI prefixes
3388 (http://www.bipm.fr/enus/3_SI/si-prefixes.html) for decimal multiples
3389 and with the IEC 60027-2 prefixes for binary multiples
3390 (http://physics.nist.gov/cuu/Units/binary.html).
3391
3392    The following suffixes are defined.  Large sizes like '1Y' may be
3393 rejected by your computer due to limitations of its arithmetic.
3394
3395 'kB'
3396      kilobyte: 10^3 = 1000.
3397 'k'
3398 'K'
3399 'KiB'
3400      kibibyte: 2^10 = 1024.  'K' is special: the SI prefix is 'k' and
3401      the IEC 60027-2 prefix is 'Ki', but tradition and POSIX use 'k' to
3402      mean 'KiB'.
3403 'MB'
3404      megabyte: 10^6 = 1,000,000.
3405 'M'
3406 'MiB'
3407      mebibyte: 2^20 = 1,048,576.
3408 'GB'
3409      gigabyte: 10^9 = 1,000,000,000.
3410 'G'
3411 'GiB'
3412      gibibyte: 2^30 = 1,073,741,824.
3413 'TB'
3414      terabyte: 10^12 = 1,000,000,000,000.
3415 'T'
3416 'TiB'
3417      tebibyte: 2^40 = 1,099,511,627,776.
3418 'PB'
3419      petabyte: 10^15 = 1,000,000,000,000,000.
3420 'P'
3421 'PiB'
3422      pebibyte: 2^50 = 1,125,899,906,842,624.
3423 'EB'
3424      exabyte: 10^18 = 1,000,000,000,000,000,000.
3425 'E'
3426 'EiB'
3427      exbibyte: 2^60 = 1,152,921,504,606,846,976.
3428 'ZB'
3429      zettabyte: 10^21 = 1,000,000,000,000,000,000,000
3430 'Z'
3431 'ZiB'
3432      2^70 = 1,180,591,620,717,411,303,424.  ('Zi' is a GNU extension to
3433      IEC 60027-2.)
3434 'YB'
3435      yottabyte: 10^24 = 1,000,000,000,000,000,000,000,000.
3436 'Y'
3437 'YiB'
3438      2^80 = 1,208,925,819,614,629,174,706,176.  ('Yi' is a GNU extension
3439      to IEC 60027-2.)
3440
3441 \1f
3442 File: diffutils.info,  Node: Invoking diff,  Next: Invoking diff3,  Prev: Invoking cmp,  Up: Top
3443
3444 13 Invoking 'diff'
3445 ******************
3446
3447 The format for running the 'diff' command is:
3448
3449      diff OPTIONS... FILES...
3450
3451    In the simplest case, two file names FROM-FILE and TO-FILE are given,
3452 and 'diff' compares the contents of FROM-FILE and TO-FILE.  A file name
3453 of '-' stands for the standard input.
3454
3455    If one file is a directory and the other is not, 'diff' compares the
3456 file in the directory whose name is that of the non-directory.  The
3457 non-directory file must not be '-'.
3458
3459    If two file names are given and both are directories, 'diff' compares
3460 corresponding files in both directories, in alphabetical order; this
3461 comparison is not recursive unless the '--recursive' ('-r') option is
3462 given.  'diff' never compares the actual contents of a directory as if
3463 it were a file.  The file that is fully specified may not be standard
3464 input, because standard input is nameless and the notion of "file with
3465 the same name" does not apply.
3466
3467    If the '--from-file=FILE' option is given, the number of file names
3468 is arbitrary, and FILE is compared to each named file.  Similarly, if
3469 the '--to-file=FILE' option is given, each named file is compared to
3470 FILE.
3471
3472    'diff' options begin with '-', so normally file names may not begin
3473 with '-'.  However, '--' as an argument by itself treats the remaining
3474 arguments as file names even if they begin with '-'.
3475
3476    An exit status of 0 means no differences were found, 1 means some
3477 differences were found, and 2 means trouble.
3478
3479 * Menu:
3480
3481 * diff Options:: Summary of options to 'diff'.
3482
3483 \1f
3484 File: diffutils.info,  Node: diff Options,  Up: Invoking diff
3485
3486 13.1 Options to 'diff'
3487 ======================
3488
3489 Below is a summary of all of the options that GNU 'diff' accepts.  Most
3490 options have two equivalent names, one of which is a single letter
3491 preceded by '-', and the other of which is a long name preceded by '--'.
3492 Multiple single letter options (unless they take an argument) can be
3493 combined into a single command line word: '-ac' is equivalent to '-a
3494 -c'.  Long named options can be abbreviated to any unique prefix of
3495 their name.  Brackets ([ and ]) indicate that an option takes an
3496 optional argument.
3497
3498 '-a'
3499 '--text'
3500      Treat all files as text and compare them line-by-line, even if they
3501      do not seem to be text.  *Note Binary::.
3502
3503 '-b'
3504 '--ignore-space-change'
3505      Ignore changes in amount of white space.  *Note White Space::.
3506
3507 '-B'
3508 '--ignore-blank-lines'
3509      Ignore changes that just insert or delete blank lines.  *Note Blank
3510      Lines::.
3511
3512 '--binary'
3513      Read and write data in binary mode.  *Note Binary::.
3514
3515 '-c'
3516      Use the context output format, showing three lines of context.
3517      *Note Context Format::.
3518
3519 '--color [=WHEN]'
3520      Specify whether to use color for distinguishing different contexts,
3521      like header, added or removed lines.  WHEN may be omitted, or one
3522      of:
3523         * none Do not use color at all.  This is the default when no
3524           -color option is specified.
3525         * auto Use color only if standard output is a terminal.
3526         * always Always use color.
3527      Specifying '--color' and no WHEN is equivalent to '--color=auto'.
3528
3529 '-C LINES'
3530 '--context[=LINES]'
3531      Use the context output format, showing LINES (an integer) lines of
3532      context, or three if LINES is not given.  *Note Context Format::.
3533      For proper operation, 'patch' typically needs at least two lines of
3534      context.
3535
3536      For compatibility 'diff' also supports an obsolete option syntax
3537      '-LINES' that has effect when combined with '-c', '-p', or '-u'.
3538      New scripts should use '-U LINES' ('-C LINES') instead.
3539
3540 '--changed-group-format=FORMAT'
3541      Use FORMAT to output a line group containing differing lines from
3542      both files in if-then-else format.  *Note Line Group Formats::.
3543
3544 '-d'
3545 '--minimal'
3546      Change the algorithm perhaps find a smaller set of changes.  This
3547      makes 'diff' slower (sometimes much slower).  *Note diff
3548      Performance::.
3549
3550 '-D NAME'
3551 '--ifdef=NAME'
3552      Make merged '#ifdef' format output, conditional on the preprocessor
3553      macro NAME.  *Note If-then-else::.
3554
3555 '-e'
3556 '--ed'
3557      Make output that is a valid 'ed' script.  *Note ed Scripts::.
3558
3559 '-E'
3560 '--ignore-tab-expansion'
3561      Ignore changes due to tab expansion.  *Note White Space::.
3562
3563 '-f'
3564 '--forward-ed'
3565      Make output that looks vaguely like an 'ed' script but has changes
3566      in the order they appear in the file.  *Note Forward ed::.
3567
3568 '-F REGEXP'
3569 '--show-function-line=REGEXP'
3570      In context and unified format, for each hunk of differences, show
3571      some of the last preceding line that matches REGEXP.  *Note
3572      Specified Headings::.
3573
3574 '--from-file=FILE'
3575      Compare FILE to each operand; FILE may be a directory.
3576
3577 '--help'
3578      Output a summary of usage and then exit.
3579
3580 '--horizon-lines=LINES'
3581      Do not discard the last LINES lines of the common prefix and the
3582      first LINES lines of the common suffix.  *Note diff Performance::.
3583
3584 '-i'
3585 '--ignore-case'
3586      Ignore changes in case; consider upper- and lower-case letters
3587      equivalent.  *Note Case Folding::.
3588
3589 '-I REGEXP'
3590 '--ignore-matching-lines=REGEXP'
3591      Ignore changes that just insert or delete lines that match REGEXP.
3592      *Note Specified Lines::.
3593
3594 '--ignore-file-name-case'
3595      Ignore case when comparing file names.  For example, recursive
3596      comparison of 'd' to 'e' might compare the contents of 'd/Init' and
3597      'e/inIt'.  At the top level, 'diff d inIt' might compare the
3598      contents of 'd/Init' and 'inIt'.  *Note Comparing Directories::.
3599
3600 '-l'
3601 '--paginate'
3602      Pass the output through 'pr' to paginate it.  *Note Pagination::.
3603
3604 '-L LABEL'
3605 '--label=LABEL'
3606      Use LABEL instead of the file name in the context format (*note
3607      Context Format::) and unified format (*note Unified Format::)
3608      headers.  *Note RCS::.
3609
3610 '--left-column'
3611      Print only the left column of two common lines in side by side
3612      format.  *Note Side by Side Format::.
3613
3614 '--line-format=FORMAT'
3615      Use FORMAT to output all input lines in if-then-else format.  *Note
3616      Line Formats::.
3617
3618 '-n'
3619 '--rcs'
3620      Output RCS-format diffs; like '-f' except that each command
3621      specifies the number of lines affected.  *Note RCS::.
3622
3623 '-N'
3624 '--new-file'
3625      If one file is missing, treat it as present but empty.  *Note
3626      Comparing Directories::.
3627
3628 '--new-group-format=FORMAT'
3629      Use FORMAT to output a group of lines taken from just the second
3630      file in if-then-else format.  *Note Line Group Formats::.
3631
3632 '--new-line-format=FORMAT'
3633      Use FORMAT to output a line taken from just the second file in
3634      if-then-else format.  *Note Line Formats::.
3635
3636 '--no-dereference'
3637      Act on symbolic links themselves instead of what they point to.
3638      Two symbolic links are deemed equal only when each points to
3639      precisely the same name.
3640
3641 '--old-group-format=FORMAT'
3642      Use FORMAT to output a group of lines taken from just the first
3643      file in if-then-else format.  *Note Line Group Formats::.
3644
3645 '--old-line-format=FORMAT'
3646      Use FORMAT to output a line taken from just the first file in
3647      if-then-else format.  *Note Line Formats::.
3648
3649 '-p'
3650 '--show-c-function'
3651      Show which C function each change is in.  *Note C Function
3652      Headings::.
3653
3654 '--palette=PALETTE'
3655      Specify what color palette to use when colored output is enabled.
3656      It defaults to 'rs=0:hd=1:ad=32:de=31:ln=36' for red deleted lines,
3657      green added lines, cyan line numbers, bold header.
3658
3659      Supported capabilities are as follows.
3660
3661      'ad=32'
3662
3663           SGR substring for added lines.  The default is green
3664           foreground.
3665
3666      'de=31'
3667
3668           SGR substring for deleted lines.  The default is red
3669           foreground.
3670
3671      'hd=1'
3672
3673           SGR substring for chunk header.  The default is bold
3674           foreground.
3675
3676      'ln=36'
3677
3678           SGR substring for line numbers.  The default is cyan
3679           foreground.
3680
3681 '-q'
3682 '--brief'
3683      Report only whether the files differ, not the details of the
3684      differences.  *Note Brief::.
3685
3686 '-r'
3687 '--recursive'
3688      When comparing directories, recursively compare any subdirectories
3689      found.  *Note Comparing Directories::.
3690
3691 '-s'
3692 '--report-identical-files'
3693      Report when two files are the same.  *Note Comparing Directories::.
3694
3695 '-S FILE'
3696 '--starting-file=FILE'
3697      When comparing directories, start with the file FILE.  This is used
3698      for resuming an aborted comparison.  *Note Comparing Directories::.
3699
3700 '--speed-large-files'
3701      Use heuristics to speed handling of large files that have numerous
3702      scattered small changes.  *Note diff Performance::.
3703
3704 '--strip-trailing-cr'
3705      Strip any trailing carriage return at the end of an input line.
3706      *Note Binary::.
3707
3708 '--suppress-common-lines'
3709      Do not print common lines in side by side format.  *Note Side by
3710      Side Format::.
3711
3712 '-t'
3713 '--expand-tabs'
3714      Expand tabs to spaces in the output, to preserve the alignment of
3715      tabs in the input files.  *Note Tabs::.
3716
3717 '-T'
3718 '--initial-tab'
3719      Output a tab rather than a space before the text of a line in
3720      normal or context format.  This causes the alignment of tabs in the
3721      line to look normal.  *Note Tabs::.
3722
3723 '--tabsize=COLUMNS'
3724      Assume that tab stops are set every COLUMNS (default 8) print
3725      columns.  *Note Tabs::.
3726
3727 '--suppress-blank-empty'
3728      Suppress any blanks before newlines when printing the
3729      representation of an empty line, when outputting normal, context,
3730      or unified format.  *Note Trailing Blanks::.
3731
3732 '--to-file=FILE'
3733      Compare each operand to FILE; FILE may be a directory.
3734
3735 '-u'
3736      Use the unified output format, showing three lines of context.
3737      *Note Unified Format::.
3738
3739 '--unchanged-group-format=FORMAT'
3740      Use FORMAT to output a group of common lines taken from both files
3741      in if-then-else format.  *Note Line Group Formats::.
3742
3743 '--unchanged-line-format=FORMAT'
3744      Use FORMAT to output a line common to both files in if-then-else
3745      format.  *Note Line Formats::.
3746
3747 '--unidirectional-new-file'
3748      If a first file is missing, treat it as present but empty.  *Note
3749      Comparing Directories::.
3750
3751 '-U LINES'
3752 '--unified[=LINES]'
3753      Use the unified output format, showing LINES (an integer) lines of
3754      context, or three if LINES is not given.  *Note Unified Format::.
3755      For proper operation, 'patch' typically needs at least two lines of
3756      context.
3757
3758      On older systems, 'diff' supports an obsolete option '-LINES' that
3759      has effect when combined with '-u'.  POSIX 1003.1-2001 (*note
3760      Standards conformance::) does not allow this; use '-U LINES'
3761      instead.
3762
3763 '-v'
3764 '--version'
3765      Output version information and then exit.
3766
3767 '-w'
3768 '--ignore-all-space'
3769      Ignore white space when comparing lines.  *Note White Space::.
3770
3771 '-W COLUMNS'
3772 '--width=COLUMNS'
3773      Output at most COLUMNS (default 130) print columns per line in side
3774      by side format.  *Note Side by Side Format::.
3775
3776 '-x PATTERN'
3777 '--exclude=PATTERN'
3778      When comparing directories, ignore files and subdirectories whose
3779      basenames match PATTERN.  *Note Comparing Directories::.
3780
3781 '-X FILE'
3782 '--exclude-from=FILE'
3783      When comparing directories, ignore files and subdirectories whose
3784      basenames match any pattern contained in FILE.  *Note Comparing
3785      Directories::.
3786
3787 '-y'
3788 '--side-by-side'
3789      Use the side by side output format.  *Note Side by Side Format::.
3790
3791 '-Z'
3792 '--ignore-trailing-space'
3793      Ignore white space at line end.  *Note White Space::.
3794
3795 \1f
3796 File: diffutils.info,  Node: Invoking diff3,  Next: Invoking patch,  Prev: Invoking diff,  Up: Top
3797
3798 14 Invoking 'diff3'
3799 *******************
3800
3801 The 'diff3' command compares three files and outputs descriptions of
3802 their differences.  Its arguments are as follows:
3803
3804      diff3 OPTIONS... MINE OLDER YOURS
3805
3806    The files to compare are MINE, OLDER, and YOURS.  At most one of
3807 these three file names may be '-', which tells 'diff3' to read the
3808 standard input for that file.
3809
3810    An exit status of 0 means 'diff3' was successful, 1 means some
3811 conflicts were found, and 2 means trouble.
3812
3813 * Menu:
3814
3815 * diff3 Options:: Summary of options to 'diff3'.
3816
3817 \1f
3818 File: diffutils.info,  Node: diff3 Options,  Up: Invoking diff3
3819
3820 14.1 Options to 'diff3'
3821 =======================
3822
3823 Below is a summary of all of the options that GNU 'diff3' accepts.
3824 Multiple single letter options (unless they take an argument) can be
3825 combined into a single command line argument.
3826
3827 '-a'
3828 '--text'
3829      Treat all files as text and compare them line-by-line, even if they
3830      do not appear to be text.  *Note Binary::.
3831
3832 '-A'
3833 '--show-all'
3834      Incorporate all unmerged changes from OLDER to YOURS into MINE,
3835      surrounding conflicts with bracket lines.  *Note Marking
3836      Conflicts::.
3837
3838 '--diff-program=PROGRAM'
3839      Use the compatible comparison program PROGRAM to compare files
3840      instead of 'diff'.
3841
3842 '-e'
3843 '--ed'
3844      Generate an 'ed' script that incorporates all the changes from
3845      OLDER to YOURS into MINE.  *Note Which Changes::.
3846
3847 '-E'
3848 '--show-overlap'
3849      Like '-e', except bracket lines from overlapping changes' first and
3850      third files.  *Note Marking Conflicts::.  With '-E', an overlapping
3851      change looks like this:
3852
3853           <<<<<<< MINE
3854           lines from MINE
3855           =======
3856           lines from YOURS
3857           >>>>>>> YOURS
3858
3859 '--help'
3860      Output a summary of usage and then exit.
3861
3862 '-i'
3863      Generate 'w' and 'q' commands at the end of the 'ed' script for
3864      System V compatibility.  This option must be combined with one of
3865      the '-AeExX3' options, and may not be combined with '-m'.  *Note
3866      Saving the Changed File::.
3867
3868 '--label=LABEL'
3869      Use the label LABEL for the brackets output by the '-A', '-E' and
3870      '-X' options.  This option may be given up to three times, one for
3871      each input file.  The default labels are the names of the input
3872      files.  Thus 'diff3 --label X --label Y --label Z -m A B C' acts
3873      like 'diff3 -m A B C', except that the output looks like it came
3874      from files named 'X', 'Y' and 'Z' rather than from files named 'A',
3875      'B' and 'C'.  *Note Marking Conflicts::.
3876
3877 '-m'
3878 '--merge'
3879      Apply the edit script to the first file and send the result to
3880      standard output.  Unlike piping the output from 'diff3' to 'ed',
3881      this works even for binary files and incomplete lines.  '-A' is
3882      assumed if no edit script option is specified.  *Note Bypassing
3883      ed::.
3884
3885 '--strip-trailing-cr'
3886      Strip any trailing carriage return at the end of an input line.
3887      *Note Binary::.
3888
3889 '-T'
3890 '--initial-tab'
3891      Output a tab rather than two spaces before the text of a line in
3892      normal format.  This causes the alignment of tabs in the line to
3893      look normal.  *Note Tabs::.
3894
3895 '-v'
3896 '--version'
3897      Output version information and then exit.
3898
3899 '-x'
3900 '--overlap-only'
3901      Like '-e', except output only the overlapping changes.  *Note Which
3902      Changes::.
3903
3904 '-X'
3905      Like '-E', except output only the overlapping changes.  In other
3906      words, like '-x', except bracket changes as in '-E'.  *Note Marking
3907      Conflicts::.
3908
3909 '-3'
3910 '--easy-only'
3911      Like '-e', except output only the nonoverlapping changes.  *Note
3912      Which Changes::.
3913
3914 \1f
3915 File: diffutils.info,  Node: Invoking patch,  Next: Invoking sdiff,  Prev: Invoking diff3,  Up: Top
3916
3917 15 Invoking 'patch'
3918 *******************
3919
3920 Normally 'patch' is invoked like this:
3921
3922      patch <PATCHFILE
3923
3924    The full format for invoking 'patch' is:
3925
3926      patch OPTIONS... [ORIGFILE [PATCHFILE]]
3927
3928    You can also specify where to read the patch from with the '-i
3929 PATCHFILE' or '--input=PATCHFILE' option.  If you do not specify
3930 PATCHFILE, or if PATCHFILE is '-', 'patch' reads the patch (that is, the
3931 'diff' output) from the standard input.
3932
3933    If you do not specify an input file on the command line, 'patch'
3934 tries to intuit from the "leading text" (any text in the patch that
3935 comes before the 'diff' output) which file to edit.  *Note Multiple
3936 Patches::.
3937
3938    By default, 'patch' replaces the original input file with the patched
3939 version, possibly after renaming the original file into a backup file
3940 (*note Backup Names::, for a description of how 'patch' names backup
3941 files).  You can also specify where to put the output with the '-o FILE'
3942 or '--output=FILE' option; however, do not use this option if FILE is
3943 one of the input files.
3944
3945 * Menu:
3946
3947 * patch Options::     Summary table of options to 'patch'.
3948
3949 \1f
3950 File: diffutils.info,  Node: patch Options,  Up: Invoking patch
3951
3952 15.1 Options to 'patch'
3953 =======================
3954
3955 Here is a summary of all of the options that GNU 'patch' accepts.  *Note
3956 patch and Tradition::, for which of these options are safe to use in
3957 older versions of 'patch'.
3958
3959    Multiple single-letter options that do not take an argument can be
3960 combined into a single command line argument with only one dash.
3961
3962 '-b'
3963 '--backup'
3964      Back up the original contents of each file, even if backups would
3965      normally not be made.  *Note Backups::.
3966
3967 '-B PREFIX'
3968 '--prefix=PREFIX'
3969      Prepend PREFIX to backup file names.  *Note Backup Names::.
3970
3971 '--backup-if-mismatch'
3972      Back up the original contents of each file if the patch does not
3973      exactly match the file.  This is the default behavior when not
3974      conforming to POSIX. *Note Backups::.
3975
3976 '--binary'
3977      Read and write all files in binary mode, except for standard output
3978      and '/dev/tty'.  This option has no effect on POSIX-conforming
3979      systems like GNU/Linux.  On systems where this option makes a
3980      difference, the patch should be generated by 'diff -a --binary'.
3981      *Note Binary::.
3982
3983 '-c'
3984 '--context'
3985      Interpret the patch file as a context diff.  *Note patch Input::.
3986
3987 '-d DIRECTORY'
3988 '--directory=DIRECTORY'
3989      Make directory DIRECTORY the current directory for interpreting
3990      both file names in the patch file, and file names given as
3991      arguments to other options.  *Note patch Directories::.
3992
3993 '-D NAME'
3994 '--ifdef=NAME'
3995      Make merged if-then-else output using NAME.  *Note If-then-else::.
3996
3997 '--dry-run'
3998      Print the results of applying the patches without actually changing
3999      any files.  *Note Dry Runs::.
4000
4001 '-e'
4002 '--ed'
4003      Interpret the patch file as an 'ed' script.  *Note patch Input::.
4004
4005 '-E'
4006 '--remove-empty-files'
4007      Remove output files that are empty after the patches have been
4008      applied.  *Note Creating and Removing::.
4009
4010 '-f'
4011 '--force'
4012      Assume that the user knows exactly what he or she is doing, and do
4013      not ask any questions.  *Note patch Messages::.
4014
4015 '-F LINES'
4016 '--fuzz=LINES'
4017      Set the maximum fuzz factor to LINES.  *Note Inexact::.
4018
4019 '-g NUM'
4020 '--get=NUM'
4021      If NUM is positive, get input files from a revision control system
4022      as necessary; if zero, do not get the files; if negative, ask the
4023      user whether to get the files.  *Note Revision Control::.
4024
4025 '--help'
4026      Output a summary of usage and then exit.
4027
4028 '-i PATCHFILE'
4029 '--input=PATCHFILE'
4030      Read the patch from PATCHFILE rather than from standard input.
4031      *Note patch Options::.
4032
4033 '-l'
4034 '--ignore-white-space'
4035      Let any sequence of blanks (spaces or tabs) in the patch file match
4036      any sequence of blanks in the input file.  *Note Changed White
4037      Space::.
4038
4039 '-n'
4040 '--normal'
4041      Interpret the patch file as a normal diff.  *Note patch Input::.
4042
4043 '-N'
4044 '--forward'
4045      Ignore patches that 'patch' thinks are reversed or already applied.
4046      See also '-R'.  *Note Reversed Patches::.
4047
4048 '--no-backup-if-mismatch'
4049      Do not back up the original contents of files.  This is the default
4050      behavior when conforming to POSIX. *Note Backups::.
4051
4052 '-o FILE'
4053 '--output=FILE'
4054      Use FILE as the output file name.  *Note patch Options::.
4055
4056 '-pNUMBER'
4057 '--strip=NUMBER'
4058      Set the file name strip count to NUMBER.  *Note patch
4059      Directories::.
4060
4061 '--posix'
4062      Conform to POSIX, as if the 'POSIXLY_CORRECT' environment variable
4063      had been set.  *Note patch and POSIX::.
4064
4065 '--quoting-style=WORD'
4066      Use style WORD to quote names in diagnostics, as if the
4067      'QUOTING_STYLE' environment variable had been set to WORD.  *Note
4068      patch Quoting Style::.
4069
4070 '-r REJECT-FILE'
4071 '--reject-file=REJECT-FILE'
4072      Use REJECT-FILE as the reject file name.  *Note Reject Names::.
4073
4074 '-R'
4075 '--reverse'
4076      Assume that this patch was created with the old and new files
4077      swapped.  *Note Reversed Patches::.
4078
4079 '-s'
4080 '--quiet'
4081 '--silent'
4082      Work silently unless an error occurs.  *Note patch Messages::.
4083
4084 '-t'
4085 '--batch'
4086      Do not ask any questions.  *Note patch Messages::.
4087
4088 '-T'
4089 '--set-time'
4090      Set the modification and access times of patched files from
4091      timestamps given in context diff headers, assuming that the context
4092      diff headers use local time.  *Note Patching Timestamps::.
4093
4094 '-u'
4095 '--unified'
4096      Interpret the patch file as a unified diff.  *Note patch Input::.
4097
4098 '-v'
4099 '--version'
4100      Output version information and then exit.
4101
4102 '-V BACKUP-STYLE'
4103 '--version=control=BACKUP-STYLE'
4104      Select the naming convention for backup file names.  *Note Backup
4105      Names::.
4106
4107 '--verbose'
4108      Print more diagnostics than usual.  *Note patch Messages::.
4109
4110 '-x NUMBER'
4111 '--debug=NUMBER'
4112      Set internal debugging flags.  Of interest only to 'patch'
4113      patchers.
4114
4115 '-Y PREFIX'
4116 '--basename-prefix=PREFIX'
4117      Prepend PREFIX to base names of backup files.  *Note Backup
4118      Names::.
4119
4120 '-z SUFFIX'
4121 '--suffix=SUFFIX'
4122      Use SUFFIX as the backup extension instead of '.orig' or '~'.
4123      *Note Backup Names::.
4124
4125 '-Z'
4126 '--set-utc'
4127      Set the modification and access times of patched files from
4128      timestamps given in context diff headers, assuming that the context
4129      diff headers use UTC. *Note Patching Timestamps::.
4130
4131 \1f
4132 File: diffutils.info,  Node: Invoking sdiff,  Next: Standards conformance,  Prev: Invoking patch,  Up: Top
4133
4134 16 Invoking 'sdiff'
4135 *******************
4136
4137 The 'sdiff' command merges two files and interactively outputs the
4138 results.  Its arguments are as follows:
4139
4140      sdiff -o OUTFILE OPTIONS... FROM-FILE TO-FILE
4141
4142    This merges FROM-FILE with TO-FILE, with output to OUTFILE.  If
4143 FROM-FILE is a directory and TO-FILE is not, 'sdiff' compares the file
4144 in FROM-FILE whose file name is that of TO-FILE, and vice versa.
4145 FROM-FILE and TO-FILE may not both be directories.
4146
4147    'sdiff' options begin with '-', so normally FROM-FILE and TO-FILE may
4148 not begin with '-'.  However, '--' as an argument by itself treats the
4149 remaining arguments as file names even if they begin with '-'.  You may
4150 not use '-' as an input file.
4151
4152    'sdiff' without '--output' ('-o') produces a side-by-side difference.
4153 This usage is obsolete; use the '--side-by-side' ('-y') option of 'diff'
4154 instead.
4155
4156    An exit status of 0 means no differences were found, 1 means some
4157 differences were found, and 2 means trouble.
4158
4159 * Menu:
4160
4161 * sdiff Options:: Summary of options to 'diff'.
4162
4163 \1f
4164 File: diffutils.info,  Node: sdiff Options,  Up: Invoking sdiff
4165
4166 16.1 Options to 'sdiff'
4167 =======================
4168
4169 Below is a summary of all of the options that GNU 'sdiff' accepts.  Each
4170 option has two equivalent names, one of which is a single letter
4171 preceded by '-', and the other of which is a long name preceded by '--'.
4172 Multiple single letter options (unless they take an argument) can be
4173 combined into a single command line argument.  Long named options can be
4174 abbreviated to any unique prefix of their name.
4175
4176 '-a'
4177 '--text'
4178      Treat all files as text and compare them line-by-line, even if they
4179      do not appear to be text.  *Note Binary::.
4180
4181 '-b'
4182 '--ignore-space-change'
4183      Ignore changes in amount of white space.  *Note White Space::.
4184
4185 '-B'
4186 '--ignore-blank-lines'
4187      Ignore changes that just insert or delete blank lines.  *Note Blank
4188      Lines::.
4189
4190 '-d'
4191 '--minimal'
4192      Change the algorithm to perhaps find a smaller set of changes.
4193      This makes 'sdiff' slower (sometimes much slower).  *Note diff
4194      Performance::.
4195
4196 '--diff-program=PROGRAM'
4197      Use the compatible comparison program PROGRAM to compare files
4198      instead of 'diff'.
4199
4200 '-E'
4201 '--ignore-tab-expansion'
4202      Ignore changes due to tab expansion.  *Note White Space::.
4203
4204 '--help'
4205      Output a summary of usage and then exit.
4206
4207 '-i'
4208 '--ignore-case'
4209      Ignore changes in case; consider upper- and lower-case to be the
4210      same.  *Note Case Folding::.
4211
4212 '-I REGEXP'
4213 '--ignore-matching-lines=REGEXP'
4214      Ignore changes that just insert or delete lines that match REGEXP.
4215      *Note Specified Lines::.
4216
4217 '-l'
4218 '--left-column'
4219      Print only the left column of two common lines.  *Note Side by Side
4220      Format::.
4221
4222 '-o FILE'
4223 '--output=FILE'
4224      Put merged output into FILE.  This option is required for merging.
4225
4226 '-s'
4227 '--suppress-common-lines'
4228      Do not print common lines.  *Note Side by Side Format::.
4229
4230 '--speed-large-files'
4231      Use heuristics to speed handling of large files that have numerous
4232      scattered small changes.  *Note diff Performance::.
4233
4234 '--strip-trailing-cr'
4235      Strip any trailing carriage return at the end of an input line.
4236      *Note Binary::.
4237
4238 '-t'
4239 '--expand-tabs'
4240      Expand tabs to spaces in the output, to preserve the alignment of
4241      tabs in the input files.  *Note Tabs::.
4242
4243 '--tabsize=COLUMNS'
4244      Assume that tab stops are set every COLUMNS (default 8) print
4245      columns.  *Note Tabs::.
4246
4247 '-v'
4248 '--version'
4249      Output version information and then exit.
4250
4251 '-w COLUMNS'
4252 '--width=COLUMNS'
4253      Output at most COLUMNS (default 130) print columns per line.  *Note
4254      Side by Side Format::.  Note that for historical reasons, this
4255      option is '-W' in 'diff', '-w' in 'sdiff'.
4256
4257 '-W'
4258 '--ignore-all-space'
4259      Ignore white space when comparing lines.  *Note White Space::.
4260      Note that for historical reasons, this option is '-w' in 'diff',
4261      '-W' in 'sdiff'.
4262
4263 '-Z'
4264 '--ignore-trailing-space'
4265      Ignore white space at line end.  *Note White Space::.
4266
4267 \1f
4268 File: diffutils.info,  Node: Standards conformance,  Next: Projects,  Prev: Invoking sdiff,  Up: Top
4269
4270 17 Standards conformance
4271 ************************
4272
4273 In a few cases, the GNU utilities' default behavior is incompatible with
4274 the POSIX standard.  To suppress these incompatibilities, define the
4275 'POSIXLY_CORRECT' environment variable.  Unless you are checking for
4276 POSIX conformance, you probably do not need to define 'POSIXLY_CORRECT'.
4277
4278    Normally options and operands can appear in any order, and programs
4279 act as if all the options appear before any operands.  For example,
4280 'diff lao tzu -C 2' acts like 'diff -C 2 lao tzu', since '2' is an
4281 option-argument of '-C'.  However, if the 'POSIXLY_CORRECT' environment
4282 variable is set, options must appear before operands, unless otherwise
4283 specified for a particular command.
4284
4285    Newer versions of POSIX are occasionally incompatible with older
4286 versions.  For example, older versions of POSIX allowed the command
4287 'diff -c -10' to have the same meaning as 'diff -C 10', but POSIX
4288 1003.1-2001 'diff' no longer allows digit-string options like '-10'.
4289
4290    The GNU utilities normally conform to the version of POSIX that is
4291 standard for your system.  To cause them to conform to a different
4292 version of POSIX, define the '_POSIX2_VERSION' environment variable to a
4293 value of the form YYYYMM specifying the year and month the standard was
4294 adopted.  Two values are currently supported for '_POSIX2_VERSION':
4295 '199209' stands for POSIX 1003.2-1992, and '200112' stands for POSIX
4296 1003.1-2001.  For example, if you are running older software that
4297 assumes an older version of POSIX and uses 'diff -c -10', you can work
4298 around the compatibility problems by setting '_POSIX2_VERSION=199209' in
4299 your environment.
4300
4301 \1f
4302 File: diffutils.info,  Node: Projects,  Next: Copying This Manual,  Prev: Standards conformance,  Up: Top
4303
4304 18 Future Projects
4305 ******************
4306
4307 Here are some ideas for improving GNU 'diff' and 'patch'.  The GNU
4308 project has identified some improvements as potential programming
4309 projects for volunteers.  You can also help by reporting any bugs that
4310 you find.
4311
4312    If you are a programmer and would like to contribute something to the
4313 GNU project, please consider volunteering for one of these projects.  If
4314 you are seriously contemplating work, please write to <gvc@gnu.org> to
4315 coordinate with other volunteers.
4316
4317 * Menu:
4318
4319 * Shortcomings:: Suggested projects for improvements.
4320 * Bugs::         Reporting bugs.
4321
4322 \1f
4323 File: diffutils.info,  Node: Shortcomings,  Next: Bugs,  Up: Projects
4324
4325 18.1 Suggested Projects for Improving GNU 'diff' and 'patch'
4326 ============================================================
4327
4328 One should be able to use GNU 'diff' to generate a patch from any pair
4329 of directory trees, and given the patch and a copy of one such tree, use
4330 'patch' to generate a faithful copy of the other.  Unfortunately, some
4331 changes to directory trees cannot be expressed using current patch
4332 formats; also, 'patch' does not handle some of the existing formats.
4333 These shortcomings motivate the following suggested projects.
4334
4335 * Menu:
4336
4337 * Internationalization:: Handling multibyte and varying-width characters.
4338 * Changing Structure::   Handling changes to the directory structure.
4339 * Special Files::        Handling symbolic links, device special files, etc.
4340 * Unusual File Names::   Handling file names that contain unusual characters.
4341 * Timestamp Order::     Outputting diffs in timestamp order.
4342 * Ignoring Changes::     Ignoring certain changes while showing others.
4343 * Speedups::             Improving performance.
4344
4345 \1f
4346 File: diffutils.info,  Node: Internationalization,  Next: Changing Structure,  Up: Shortcomings
4347
4348 18.1.1 Handling Multibyte and Varying-Width Characters
4349 ------------------------------------------------------
4350
4351 'diff', 'diff3' and 'sdiff' treat each line of input as a string of
4352 unibyte characters.  This can mishandle multibyte characters in some
4353 cases.  For example, when asked to ignore spaces, 'diff' does not
4354 properly ignore a multibyte space character.
4355
4356    Also, 'diff' currently assumes that each byte is one column wide, and
4357 this assumption is incorrect in some locales, e.g., locales that use
4358 UTF-8 encoding.  This causes problems with the '-y' or '--side-by-side'
4359 option of 'diff'.
4360
4361    These problems need to be fixed without unduly affecting the
4362 performance of the utilities in unibyte environments.
4363
4364    The IBM GNU/Linux Technology Center Internationalization Team has
4365 proposed patches to support internationalized 'diff'
4366 (http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.patch.gz).
4367 Unfortunately, these patches are incomplete and are to an older version
4368 of 'diff', so more work needs to be done in this area.
4369
4370 \1f
4371 File: diffutils.info,  Node: Changing Structure,  Next: Special Files,  Prev: Internationalization,  Up: Shortcomings
4372
4373 18.1.2 Handling Changes to the Directory Structure
4374 --------------------------------------------------
4375
4376 'diff' and 'patch' do not handle some changes to directory structure.
4377 For example, suppose one directory tree contains a directory named 'D'
4378 with some subsidiary files, and another contains a file with the same
4379 name 'D'.  'diff -r' does not output enough information for 'patch' to
4380 transform the directory subtree into the file.
4381
4382    There should be a way to specify that a file has been removed without
4383 having to include its entire contents in the patch file.  There should
4384 also be a way to tell 'patch' that a file was renamed, even if there is
4385 no way for 'diff' to generate such information.  There should be a way
4386 to tell 'patch' that a file's timestamp has changed, even if its
4387 contents have not changed.
4388
4389    These problems can be fixed by extending the 'diff' output format to
4390 represent changes in directory structure, and extending 'patch' to
4391 understand these extensions.
4392
4393 \1f
4394 File: diffutils.info,  Node: Special Files,  Next: Unusual File Names,  Prev: Changing Structure,  Up: Shortcomings
4395
4396 18.1.3 Files that are Neither Directories Nor Regular Files
4397 -----------------------------------------------------------
4398
4399 Some files are neither directories nor regular files: they are unusual
4400 files like symbolic links, device special files, named pipes, and
4401 sockets.  Currently, 'diff' treats symbolic links as if they were the
4402 pointed-to files, except that a recursive 'diff' reports an error if it
4403 detects infinite loops of symbolic links (e.g., symbolic links to '..').
4404 'diff' treats other special files like regular files if they are
4405 specified at the top level, but simply reports their presence when
4406 comparing directories.  This means that 'patch' cannot represent changes
4407 to such files.  For example, if you change which file a symbolic link
4408 points to, 'diff' outputs the difference between the two files, instead
4409 of the change to the symbolic link.
4410
4411    'diff' should optionally report changes to special files specially,
4412 and 'patch' should be extended to understand these extensions.
4413
4414 \1f
4415 File: diffutils.info,  Node: Unusual File Names,  Next: Timestamp Order,  Prev: Special Files,  Up: Shortcomings
4416
4417 18.1.4 File Names that Contain Unusual Characters
4418 -------------------------------------------------
4419
4420 When a file name contains an unusual character like a newline or white
4421 space, 'diff -r' generates a patch that 'patch' cannot parse.  The
4422 problem is with format of 'diff' output, not just with 'patch', because
4423 with odd enough file names one can cause 'diff' to generate a patch that
4424 is syntactically correct but patches the wrong files.  The format of
4425 'diff' output should be extended to handle all possible file names.
4426
4427 \1f
4428 File: diffutils.info,  Node: Timestamp Order,  Next: Ignoring Changes,  Prev: Unusual File Names,  Up: Shortcomings
4429
4430 18.1.5 Outputting Diffs in Timestamp Order
4431 ------------------------------------------
4432
4433 Applying 'patch' to a multiple-file diff can result in files whose
4434 timestamps are out of order.  GNU 'patch' has options to restore the
4435 timestamps of the updated files (*note Patching Timestamps::), but
4436 sometimes it is useful to generate a patch that works even if the
4437 recipient does not have GNU patch, or does not use these options.  One
4438 way to do this would be to implement a 'diff' option to output diffs in
4439 timestamp order.
4440
4441 \1f
4442 File: diffutils.info,  Node: Ignoring Changes,  Next: Speedups,  Prev: Timestamp Order,  Up: Shortcomings
4443
4444 18.1.6 Ignoring Certain Changes
4445 -------------------------------
4446
4447 It would be nice to have a feature for specifying two strings, one in
4448 FROM-FILE and one in TO-FILE, which should be considered to match.
4449 Thus, if the two strings are 'foo' and 'bar', then if two lines differ
4450 only in that 'foo' in file 1 corresponds to 'bar' in file 2, the lines
4451 are treated as identical.
4452
4453    It is not clear how general this feature can or should be, or what
4454 syntax should be used for it.
4455
4456    A partial substitute is to filter one or both files before comparing,
4457 e.g.:
4458
4459      sed 's/foo/bar/g' file1 | diff - file2
4460
4461    However, this outputs the filtered text, not the original.
4462
4463 \1f
4464 File: diffutils.info,  Node: Speedups,  Prev: Ignoring Changes,  Up: Shortcomings
4465
4466 18.1.7 Improving Performance
4467 ----------------------------
4468
4469 When comparing two large directory structures, one of which was
4470 originally copied from the other with timestamps preserved (e.g., with
4471 'cp -pR'), it would greatly improve performance if an option told 'diff'
4472 to assume that two files with the same size and timestamps have the same
4473 content.  *Note diff Performance::.
4474
4475 \1f
4476 File: diffutils.info,  Node: Bugs,  Prev: Shortcomings,  Up: Projects
4477
4478 18.2 Reporting Bugs
4479 ===================
4480
4481 If you think you have found a bug in GNU 'cmp', 'diff', 'diff3', or
4482 'sdiff', please report it by electronic mail to the GNU utilities bug
4483 report mailing list (http://mail.gnu.org/mailman/listinfo/bug-diffutils)
4484 <bug-diffutils@gnu.org>.  Please send bug reports for GNU 'patch' to
4485 <bug-patch@gnu.org>.  Send as precise a description of the problem as
4486 you can, including the output of the '--version' option and sample input
4487 files that produce the bug, if applicable.  If you have a nontrivial fix
4488 for the bug, please send it as well.  If you have a patch, please send
4489 it too.  It may simplify the maintainer's job if the patch is relative
4490 to a recent test release, which you can find in the directory
4491 <ftp://alpha.gnu.org/gnu/diffutils/>.
4492
4493 \1f
4494 File: diffutils.info,  Node: Copying This Manual,  Next: Translations,  Prev: Projects,  Up: Top
4495
4496 Appendix A Copying This Manual
4497 ******************************
4498
4499                      Version 1.3, 3 November 2008
4500
4501      Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
4502      <https://fsf.org/>
4503
4504      Everyone is permitted to copy and distribute verbatim copies
4505      of this license document, but changing it is not allowed.
4506
4507   0. PREAMBLE
4508
4509      The purpose of this License is to make a manual, textbook, or other
4510      functional and useful document "free" in the sense of freedom: to
4511      assure everyone the effective freedom to copy and redistribute it,
4512      with or without modifying it, either commercially or
4513      noncommercially.  Secondarily, this License preserves for the
4514      author and publisher a way to get credit for their work, while not
4515      being considered responsible for modifications made by others.
4516
4517      This License is a kind of "copyleft", which means that derivative
4518      works of the document must themselves be free in the same sense.
4519      It complements the GNU General Public License, which is a copyleft
4520      license designed for free software.
4521
4522      We have designed this License in order to use it for manuals for
4523      free software, because free software needs free documentation: a
4524      free program should come with manuals providing the same freedoms
4525      that the software does.  But this License is not limited to
4526      software manuals; it can be used for any textual work, regardless
4527      of subject matter or whether it is published as a printed book.  We
4528      recommend this License principally for works whose purpose is
4529      instruction or reference.
4530
4531   1. APPLICABILITY AND DEFINITIONS
4532
4533      This License applies to any manual or other work, in any medium,
4534      that contains a notice placed by the copyright holder saying it can
4535      be distributed under the terms of this License.  Such a notice
4536      grants a world-wide, royalty-free license, unlimited in duration,
4537      to use that work under the conditions stated herein.  The
4538      "Document", below, refers to any such manual or work.  Any member
4539      of the public is a licensee, and is addressed as "you".  You accept
4540      the license if you copy, modify or distribute the work in a way
4541      requiring permission under copyright law.
4542
4543      A "Modified Version" of the Document means any work containing the
4544      Document or a portion of it, either copied verbatim, or with
4545      modifications and/or translated into another language.
4546
4547      A "Secondary Section" is a named appendix or a front-matter section
4548      of the Document that deals exclusively with the relationship of the
4549      publishers or authors of the Document to the Document's overall
4550      subject (or to related matters) and contains nothing that could
4551      fall directly within that overall subject.  (Thus, if the Document
4552      is in part a textbook of mathematics, a Secondary Section may not
4553      explain any mathematics.)  The relationship could be a matter of
4554      historical connection with the subject or with related matters, or
4555      of legal, commercial, philosophical, ethical or political position
4556      regarding them.
4557
4558      The "Invariant Sections" are certain Secondary Sections whose
4559      titles are designated, as being those of Invariant Sections, in the
4560      notice that says that the Document is released under this License.
4561      If a section does not fit the above definition of Secondary then it
4562      is not allowed to be designated as Invariant.  The Document may
4563      contain zero Invariant Sections.  If the Document does not identify
4564      any Invariant Sections then there are none.
4565
4566      The "Cover Texts" are certain short passages of text that are
4567      listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4568      that says that the Document is released under this License.  A
4569      Front-Cover Text may be at most 5 words, and a Back-Cover Text may
4570      be at most 25 words.
4571
4572      A "Transparent" copy of the Document means a machine-readable copy,
4573      represented in a format whose specification is available to the
4574      general public, that is suitable for revising the document
4575      straightforwardly with generic text editors or (for images composed
4576      of pixels) generic paint programs or (for drawings) some widely
4577      available drawing editor, and that is suitable for input to text
4578      formatters or for automatic translation to a variety of formats
4579      suitable for input to text formatters.  A copy made in an otherwise
4580      Transparent file format whose markup, or absence of markup, has
4581      been arranged to thwart or discourage subsequent modification by
4582      readers is not Transparent.  An image format is not Transparent if
4583      used for any substantial amount of text.  A copy that is not
4584      "Transparent" is called "Opaque".
4585
4586      Examples of suitable formats for Transparent copies include plain
4587      ASCII without markup, Texinfo input format, LaTeX input format,
4588      SGML or XML using a publicly available DTD, and standard-conforming
4589      simple HTML, PostScript or PDF designed for human modification.
4590      Examples of transparent image formats include PNG, XCF and JPG.
4591      Opaque formats include proprietary formats that can be read and
4592      edited only by proprietary word processors, SGML or XML for which
4593      the DTD and/or processing tools are not generally available, and
4594      the machine-generated HTML, PostScript or PDF produced by some word
4595      processors for output purposes only.
4596
4597      The "Title Page" means, for a printed book, the title page itself,
4598      plus such following pages as are needed to hold, legibly, the
4599      material this License requires to appear in the title page.  For
4600      works in formats which do not have any title page as such, "Title
4601      Page" means the text near the most prominent appearance of the
4602      work's title, preceding the beginning of the body of the text.
4603
4604      The "publisher" means any person or entity that distributes copies
4605      of the Document to the public.
4606
4607      A section "Entitled XYZ" means a named subunit of the Document
4608      whose title either is precisely XYZ or contains XYZ in parentheses
4609      following text that translates XYZ in another language.  (Here XYZ
4610      stands for a specific section name mentioned below, such as
4611      "Acknowledgements", "Dedications", "Endorsements", or "History".)
4612      To "Preserve the Title" of such a section when you modify the
4613      Document means that it remains a section "Entitled XYZ" according
4614      to this definition.
4615
4616      The Document may include Warranty Disclaimers next to the notice
4617      which states that this License applies to the Document.  These
4618      Warranty Disclaimers are considered to be included by reference in
4619      this License, but only as regards disclaiming warranties: any other
4620      implication that these Warranty Disclaimers may have is void and
4621      has no effect on the meaning of this License.
4622
4623   2. VERBATIM COPYING
4624
4625      You may copy and distribute the Document in any medium, either
4626      commercially or noncommercially, provided that this License, the
4627      copyright notices, and the license notice saying this License
4628      applies to the Document are reproduced in all copies, and that you
4629      add no other conditions whatsoever to those of this License.  You
4630      may not use technical measures to obstruct or control the reading
4631      or further copying of the copies you make or distribute.  However,
4632      you may accept compensation in exchange for copies.  If you
4633      distribute a large enough number of copies you must also follow the
4634      conditions in section 3.
4635
4636      You may also lend copies, under the same conditions stated above,
4637      and you may publicly display copies.
4638
4639   3. COPYING IN QUANTITY
4640
4641      If you publish printed copies (or copies in media that commonly
4642      have printed covers) of the Document, numbering more than 100, and
4643      the Document's license notice requires Cover Texts, you must
4644      enclose the copies in covers that carry, clearly and legibly, all
4645      these Cover Texts: Front-Cover Texts on the front cover, and
4646      Back-Cover Texts on the back cover.  Both covers must also clearly
4647      and legibly identify you as the publisher of these copies.  The
4648      front cover must present the full title with all words of the title
4649      equally prominent and visible.  You may add other material on the
4650      covers in addition.  Copying with changes limited to the covers, as
4651      long as they preserve the title of the Document and satisfy these
4652      conditions, can be treated as verbatim copying in other respects.
4653
4654      If the required texts for either cover are too voluminous to fit
4655      legibly, you should put the first ones listed (as many as fit
4656      reasonably) on the actual cover, and continue the rest onto
4657      adjacent pages.
4658
4659      If you publish or distribute Opaque copies of the Document
4660      numbering more than 100, you must either include a machine-readable
4661      Transparent copy along with each Opaque copy, or state in or with
4662      each Opaque copy a computer-network location from which the general
4663      network-using public has access to download using public-standard
4664      network protocols a complete Transparent copy of the Document, free
4665      of added material.  If you use the latter option, you must take
4666      reasonably prudent steps, when you begin distribution of Opaque
4667      copies in quantity, to ensure that this Transparent copy will
4668      remain thus accessible at the stated location until at least one
4669      year after the last time you distribute an Opaque copy (directly or
4670      through your agents or retailers) of that edition to the public.
4671
4672      It is requested, but not required, that you contact the authors of
4673      the Document well before redistributing any large number of copies,
4674      to give them a chance to provide you with an updated version of the
4675      Document.
4676
4677   4. MODIFICATIONS
4678
4679      You may copy and distribute a Modified Version of the Document
4680      under the conditions of sections 2 and 3 above, provided that you
4681      release the Modified Version under precisely this License, with the
4682      Modified Version filling the role of the Document, thus licensing
4683      distribution and modification of the Modified Version to whoever
4684      possesses a copy of it.  In addition, you must do these things in
4685      the Modified Version:
4686
4687        A. Use in the Title Page (and on the covers, if any) a title
4688           distinct from that of the Document, and from those of previous
4689           versions (which should, if there were any, be listed in the
4690           History section of the Document).  You may use the same title
4691           as a previous version if the original publisher of that
4692           version gives permission.
4693
4694        B. List on the Title Page, as authors, one or more persons or
4695           entities responsible for authorship of the modifications in
4696           the Modified Version, together with at least five of the
4697           principal authors of the Document (all of its principal
4698           authors, if it has fewer than five), unless they release you
4699           from this requirement.
4700
4701        C. State on the Title page the name of the publisher of the
4702           Modified Version, as the publisher.
4703
4704        D. Preserve all the copyright notices of the Document.
4705
4706        E. Add an appropriate copyright notice for your modifications
4707           adjacent to the other copyright notices.
4708
4709        F. Include, immediately after the copyright notices, a license
4710           notice giving the public permission to use the Modified
4711           Version under the terms of this License, in the form shown in
4712           the Addendum below.
4713
4714        G. Preserve in that license notice the full lists of Invariant
4715           Sections and required Cover Texts given in the Document's
4716           license notice.
4717
4718        H. Include an unaltered copy of this License.
4719
4720        I. Preserve the section Entitled "History", Preserve its Title,
4721           and add to it an item stating at least the title, year, new
4722           authors, and publisher of the Modified Version as given on the
4723           Title Page.  If there is no section Entitled "History" in the
4724           Document, create one stating the title, year, authors, and
4725           publisher of the Document as given on its Title Page, then add
4726           an item describing the Modified Version as stated in the
4727           previous sentence.
4728
4729        J. Preserve the network location, if any, given in the Document
4730           for public access to a Transparent copy of the Document, and
4731           likewise the network locations given in the Document for
4732           previous versions it was based on.  These may be placed in the
4733           "History" section.  You may omit a network location for a work
4734           that was published at least four years before the Document
4735           itself, or if the original publisher of the version it refers
4736           to gives permission.
4737
4738        K. For any section Entitled "Acknowledgements" or "Dedications",
4739           Preserve the Title of the section, and preserve in the section
4740           all the substance and tone of each of the contributor
4741           acknowledgements and/or dedications given therein.
4742
4743        L. Preserve all the Invariant Sections of the Document, unaltered
4744           in their text and in their titles.  Section numbers or the
4745           equivalent are not considered part of the section titles.
4746
4747        M. Delete any section Entitled "Endorsements".  Such a section
4748           may not be included in the Modified Version.
4749
4750        N. Do not retitle any existing section to be Entitled
4751           "Endorsements" or to conflict in title with any Invariant
4752           Section.
4753
4754        O. Preserve any Warranty Disclaimers.
4755
4756      If the Modified Version includes new front-matter sections or
4757      appendices that qualify as Secondary Sections and contain no
4758      material copied from the Document, you may at your option designate
4759      some or all of these sections as invariant.  To do this, add their
4760      titles to the list of Invariant Sections in the Modified Version's
4761      license notice.  These titles must be distinct from any other
4762      section titles.
4763
4764      You may add a section Entitled "Endorsements", provided it contains
4765      nothing but endorsements of your Modified Version by various
4766      parties--for example, statements of peer review or that the text
4767      has been approved by an organization as the authoritative
4768      definition of a standard.
4769
4770      You may add a passage of up to five words as a Front-Cover Text,
4771      and a passage of up to 25 words as a Back-Cover Text, to the end of
4772      the list of Cover Texts in the Modified Version.  Only one passage
4773      of Front-Cover Text and one of Back-Cover Text may be added by (or
4774      through arrangements made by) any one entity.  If the Document
4775      already includes a cover text for the same cover, previously added
4776      by you or by arrangement made by the same entity you are acting on
4777      behalf of, you may not add another; but you may replace the old
4778      one, on explicit permission from the previous publisher that added
4779      the old one.
4780
4781      The author(s) and publisher(s) of the Document do not by this
4782      License give permission to use their names for publicity for or to
4783      assert or imply endorsement of any Modified Version.
4784
4785   5. COMBINING DOCUMENTS
4786
4787      You may combine the Document with other documents released under
4788      this License, under the terms defined in section 4 above for
4789      modified versions, provided that you include in the combination all
4790      of the Invariant Sections of all of the original documents,
4791      unmodified, and list them all as Invariant Sections of your
4792      combined work in its license notice, and that you preserve all
4793      their Warranty Disclaimers.
4794
4795      The combined work need only contain one copy of this License, and
4796      multiple identical Invariant Sections may be replaced with a single
4797      copy.  If there are multiple Invariant Sections with the same name
4798      but different contents, make the title of each such section unique
4799      by adding at the end of it, in parentheses, the name of the
4800      original author or publisher of that section if known, or else a
4801      unique number.  Make the same adjustment to the section titles in
4802      the list of Invariant Sections in the license notice of the
4803      combined work.
4804
4805      In the combination, you must combine any sections Entitled
4806      "History" in the various original documents, forming one section
4807      Entitled "History"; likewise combine any sections Entitled
4808      "Acknowledgements", and any sections Entitled "Dedications".  You
4809      must delete all sections Entitled "Endorsements."
4810
4811   6. COLLECTIONS OF DOCUMENTS
4812
4813      You may make a collection consisting of the Document and other
4814      documents released under this License, and replace the individual
4815      copies of this License in the various documents with a single copy
4816      that is included in the collection, provided that you follow the
4817      rules of this License for verbatim copying of each of the documents
4818      in all other respects.
4819
4820      You may extract a single document from such a collection, and
4821      distribute it individually under this License, provided you insert
4822      a copy of this License into the extracted document, and follow this
4823      License in all other respects regarding verbatim copying of that
4824      document.
4825
4826   7. AGGREGATION WITH INDEPENDENT WORKS
4827
4828      A compilation of the Document or its derivatives with other
4829      separate and independent documents or works, in or on a volume of a
4830      storage or distribution medium, is called an "aggregate" if the
4831      copyright resulting from the compilation is not used to limit the
4832      legal rights of the compilation's users beyond what the individual
4833      works permit.  When the Document is included in an aggregate, this
4834      License does not apply to the other works in the aggregate which
4835      are not themselves derivative works of the Document.
4836
4837      If the Cover Text requirement of section 3 is applicable to these
4838      copies of the Document, then if the Document is less than one half
4839      of the entire aggregate, the Document's Cover Texts may be placed
4840      on covers that bracket the Document within the aggregate, or the
4841      electronic equivalent of covers if the Document is in electronic
4842      form.  Otherwise they must appear on printed covers that bracket
4843      the whole aggregate.
4844
4845   8. TRANSLATION
4846
4847      Translation is considered a kind of modification, so you may
4848      distribute translations of the Document under the terms of section
4849      4.  Replacing Invariant Sections with translations requires special
4850      permission from their copyright holders, but you may include
4851      translations of some or all Invariant Sections in addition to the
4852      original versions of these Invariant Sections.  You may include a
4853      translation of this License, and all the license notices in the
4854      Document, and any Warranty Disclaimers, provided that you also
4855      include the original English version of this License and the
4856      original versions of those notices and disclaimers.  In case of a
4857      disagreement between the translation and the original version of
4858      this License or a notice or disclaimer, the original version will
4859      prevail.
4860
4861      If a section in the Document is Entitled "Acknowledgements",
4862      "Dedications", or "History", the requirement (section 4) to
4863      Preserve its Title (section 1) will typically require changing the
4864      actual title.
4865
4866   9. TERMINATION
4867
4868      You may not copy, modify, sublicense, or distribute the Document
4869      except as expressly provided under this License.  Any attempt
4870      otherwise to copy, modify, sublicense, or distribute it is void,
4871      and will automatically terminate your rights under this License.
4872
4873      However, if you cease all violation of this License, then your
4874      license from a particular copyright holder is reinstated (a)
4875      provisionally, unless and until the copyright holder explicitly and
4876      finally terminates your license, and (b) permanently, if the
4877      copyright holder fails to notify you of the violation by some
4878      reasonable means prior to 60 days after the cessation.
4879
4880      Moreover, your license from a particular copyright holder is
4881      reinstated permanently if the copyright holder notifies you of the
4882      violation by some reasonable means, this is the first time you have
4883      received notice of violation of this License (for any work) from
4884      that copyright holder, and you cure the violation prior to 30 days
4885      after your receipt of the notice.
4886
4887      Termination of your rights under this section does not terminate
4888      the licenses of parties who have received copies or rights from you
4889      under this License.  If your rights have been terminated and not
4890      permanently reinstated, receipt of a copy of some or all of the
4891      same material does not give you any rights to use it.
4892
4893   10. FUTURE REVISIONS OF THIS LICENSE
4894
4895      The Free Software Foundation may publish new, revised versions of
4896      the GNU Free Documentation License from time to time.  Such new
4897      versions will be similar in spirit to the present version, but may
4898      differ in detail to address new problems or concerns.  See
4899      <https://www.gnu.org/licenses/>.
4900
4901      Each version of the License is given a distinguishing version
4902      number.  If the Document specifies that a particular numbered
4903      version of this License "or any later version" applies to it, you
4904      have the option of following the terms and conditions either of
4905      that specified version or of any later version that has been
4906      published (not as a draft) by the Free Software Foundation.  If the
4907      Document does not specify a version number of this License, you may
4908      choose any version ever published (not as a draft) by the Free
4909      Software Foundation.  If the Document specifies that a proxy can
4910      decide which future versions of this License can be used, that
4911      proxy's public statement of acceptance of a version permanently
4912      authorizes you to choose that version for the Document.
4913
4914   11. RELICENSING
4915
4916      "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
4917      World Wide Web server that publishes copyrightable works and also
4918      provides prominent facilities for anybody to edit those works.  A
4919      public wiki that anybody can edit is an example of such a server.
4920      A "Massive Multiauthor Collaboration" (or "MMC") contained in the
4921      site means any set of copyrightable works thus published on the MMC
4922      site.
4923
4924      "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
4925      license published by Creative Commons Corporation, a not-for-profit
4926      corporation with a principal place of business in San Francisco,
4927      California, as well as future copyleft versions of that license
4928      published by that same organization.
4929
4930      "Incorporate" means to publish or republish a Document, in whole or
4931      in part, as part of another Document.
4932
4933      An MMC is "eligible for relicensing" if it is licensed under this
4934      License, and if all works that were first published under this
4935      License somewhere other than this MMC, and subsequently
4936      incorporated in whole or in part into the MMC, (1) had no cover
4937      texts or invariant sections, and (2) were thus incorporated prior
4938      to November 1, 2008.
4939
4940      The operator of an MMC Site may republish an MMC contained in the
4941      site under CC-BY-SA on the same site at any time before August 1,
4942      2009, provided the MMC is eligible for relicensing.
4943
4944 ADDENDUM: How to use this License for your documents
4945 ====================================================
4946
4947 To use this License in a document you have written, include a copy of
4948 the License in the document and put the following copyright and license
4949 notices just after the title page:
4950
4951        Copyright (C)  YEAR  YOUR NAME.
4952        Permission is granted to copy, distribute and/or modify this document
4953        under the terms of the GNU Free Documentation License, Version 1.3
4954        or any later version published by the Free Software Foundation;
4955        with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
4956        Texts.  A copy of the license is included in the section entitled ``GNU
4957        Free Documentation License''.
4958
4959    If you have Invariant Sections, Front-Cover Texts and Back-Cover
4960 Texts, replace the "with...Texts." line with this:
4961
4962          with the Invariant Sections being LIST THEIR TITLES, with
4963          the Front-Cover Texts being LIST, and with the Back-Cover Texts
4964          being LIST.
4965
4966    If you have Invariant Sections without Cover Texts, or some other
4967 combination of the three, merge those two alternatives to suit the
4968 situation.
4969
4970    If your document contains nontrivial examples of program code, we
4971 recommend releasing these examples in parallel under your choice of free
4972 software license, such as the GNU General Public License, to permit
4973 their use in free software.
4974
4975 \1f
4976 File: diffutils.info,  Node: Translations,  Next: Index,  Prev: Copying This Manual,  Up: Top
4977
4978 Appendix B Translations of This Manual
4979 **************************************
4980
4981 Nishio Futoshi of the GNUjdoc project has prepared a Japanese
4982 translation of this manual.  Its most recent version can be found at
4983 <http://openlab.ring.gr.jp/gnujdoc/cvsweb/cvsweb.cgi/gnujdoc/>.
4984
4985 \1f
4986 File: diffutils.info,  Node: Index,  Prev: Translations,  Up: Top
4987
4988 Appendix C Index
4989 ****************
4990
4991 \0\b[index\0\b]
4992 * Menu:
4993
4994 * ! output format:                       Context.             (line   6)
4995 * +- output format:                      Unified Format.      (line   6)
4996 * < output format:                       Normal.              (line   6)
4997 * <<<<<<< for marking conflicts:         Marking Conflicts.   (line   6)
4998 * _POSIX2_VERSION:                       Standards conformance.
4999                                                               (line  23)
5000 * ad capability:                         diff Options.        (line 179)
5001 * aligning tab stops:                    Tabs.                (line   6)
5002 * alternate file names:                  Alternate Names.     (line   6)
5003 * always color option:                   diff Options.        (line  43)
5004 * auto color option:                     diff Options.        (line  42)
5005 * backup file names:                     Backup Names.        (line   6)
5006 * backup file strategy:                  Backups.             (line   6)
5007 * binary file diff:                      Binary.              (line   6)
5008 * blank and tab difference suppression:  White Space.         (line   6)
5009 * blank line difference suppression:     Blank Lines.         (line   6)
5010 * brief difference reports:              Brief.               (line   6)
5011 * bug reports:                           Bugs.                (line   6)
5012 * C function headings:                   C Function Headings. (line   6)
5013 * C if-then-else output format:          If-then-else.        (line   6)
5014 * case difference suppression:           Case Folding.        (line   6)
5015 * ClearCase:                             Revision Control.    (line   6)
5016 * cmp invocation:                        Invoking cmp.        (line   6)
5017 * cmp options:                           cmp Options.         (line   6)
5018 * color, distinguishing different context: diff Options.      (line  37)
5019 * columnar output:                       Side by Side.        (line   6)
5020 * common mistakes with patches:          Avoiding Common Mistakes.
5021                                                               (line   6)
5022 * comparing three files:                 Comparing Three Files.
5023                                                               (line   6)
5024 * conflict:                              diff3 Merging.       (line  26)
5025 * conflict marking:                      Marking Conflicts.   (line   6)
5026 * context output format:                 Context.             (line   6)
5027 * creating files:                        Creating and Removing.
5028                                                               (line   6)
5029 * de capability:                         diff Options.        (line 184)
5030 * diagnostics from patch:                patch Messages.      (line   6)
5031 * diff invocation:                       Invoking diff.       (line   6)
5032 * diff merging:                          Interactive Merging. (line   6)
5033 * diff options:                          diff Options.        (line   6)
5034 * diff sample input:                     Sample diff Input.   (line   6)
5035 * diff3 hunks:                           diff3 Hunks.         (line   6)
5036 * diff3 invocation:                      Invoking diff3.      (line   6)
5037 * diff3 options:                         diff3 Options.       (line   6)
5038 * diff3 sample input:                    Sample diff3 Input.  (line   6)
5039 * directories and patch:                 patch Directories.   (line   6)
5040 * directory structure changes:           Changing Structure.  (line   6)
5041 * dry runs for patch:                    Dry Runs.            (line   6)
5042 * ed script output format:               ed Scripts.          (line   6)
5043 * EDITOR:                                Merge Commands.      (line  50)
5044 * empty files, removing:                 Creating and Removing.
5045                                                               (line   6)
5046 * exabyte, definition of:                cmp Options.         (line  99)
5047 * exbibyte, definition of:               cmp Options.         (line 102)
5048 * file name alternates:                  Alternate Names.     (line   6)
5049 * file names with unusual characters:    Unusual File Names.  (line   6)
5050 * format of diff output:                 Output Formats.      (line   6)
5051 * format of diff3 output:                Comparing Three Files.
5052                                                               (line   6)
5053 * formats for if-then-else line groups:  Line Group Formats.  (line   6)
5054 * forward ed script output format:       Forward ed.          (line   6)
5055 * full lines:                            Incomplete Lines.    (line   6)
5056 * function headings, C:                  C Function Headings. (line   6)
5057 * fuzz factor when patching:             Inexact.             (line   6)
5058 * gibibyte, definition of:               cmp Options.         (line  87)
5059 * gigabyte, definition of:               cmp Options.         (line  84)
5060 * hd capability:                         diff Options.        (line 189)
5061 * headings:                              Sections.            (line   6)
5062 * hunks:                                 Hunks.               (line   6)
5063 * hunks for diff3:                       diff3 Hunks.         (line   6)
5064 * if-then-else output format:            If-then-else.        (line   6)
5065 * ifdef output format:                   If-then-else.        (line   6)
5066 * imperfect patch application:           Imperfect.           (line   6)
5067 * incomplete line merging:               Merging Incomplete Lines.
5068                                                               (line   6)
5069 * incomplete lines:                      Incomplete Lines.    (line   6)
5070 * inexact patches:                       Inexact.             (line   6)
5071 * inhibit messages from patch:           More or Fewer Messages.
5072                                                               (line   6)
5073 * interactive merging:                   Interactive Merging. (line   6)
5074 * introduction:                          Comparison.          (line   6)
5075 * intuiting file names from patches:     Multiple Patches.    (line   6)
5076 * invoking cmp:                          Invoking cmp.        (line   6)
5077 * invoking diff:                         Invoking diff.       (line   6)
5078 * invoking diff3:                        Invoking diff3.      (line   6)
5079 * invoking patch:                        Invoking patch.      (line   6)
5080 * invoking sdiff:                        Invoking sdiff.      (line   6)
5081 * keyboard input to patch:               patch and Keyboard Input.
5082                                                               (line   6)
5083 * kibibyte, definition of:               cmp Options.         (line  75)
5084 * kilobyte, definition of:               cmp Options.         (line  71)
5085 * LC_COLLATE:                            Comparing Directories.
5086                                                               (line   6)
5087 * LC_NUMERIC:                            Line Group Formats.  (line 143)
5088 * LC_TIME:                               Detailed Context.    (line  12)
5089 * line formats:                          Line Formats.        (line   6)
5090 * line group formats:                    Line Group Formats.  (line   6)
5091 * ln capability:                         diff Options.        (line 194)
5092 * mebibyte, definition of:               cmp Options.         (line  82)
5093 * megabyte, definition of:               cmp Options.         (line  79)
5094 * merge commands:                        Merge Commands.      (line   6)
5095 * merged diff3 format:                   Bypassing ed.        (line   6)
5096 * merged output format:                  If-then-else.        (line   6)
5097 * merging from a common ancestor:        diff3 Merging.       (line   6)
5098 * merging interactively:                 Merge Commands.      (line   6)
5099 * messages from patch:                   patch Messages.      (line   6)
5100 * multibyte characters:                  Internationalization.
5101                                                               (line   6)
5102 * multiple patches:                      Multiple Patches.    (line   6)
5103 * newline treatment by diff:             Incomplete Lines.    (line   6)
5104 * none color option:                     diff Options.        (line  40)
5105 * normal output format:                  Normal.              (line   6)
5106 * options for cmp:                       cmp Options.         (line   6)
5107 * options for diff:                      diff Options.        (line   6)
5108 * options for diff3:                     diff3 Options.       (line   6)
5109 * options for patch:                     patch Options.       (line   6)
5110 * options for sdiff:                     sdiff Options.       (line   6)
5111 * output formats:                        Output Formats.      (line   6)
5112 * overlap:                               diff3 Merging.       (line  26)
5113 * overlapping change, selection of:      Which Changes.       (line   6)
5114 * overview of diff and patch:            Overview.            (line   6)
5115 * paginating diff output:                Pagination.          (line   6)
5116 * patch consumer tips:                   Tips for Patch Consumers.
5117                                                               (line   6)
5118 * patch input format:                    patch Input.         (line   6)
5119 * patch invocation:                      Invoking patch.      (line   6)
5120 * patch messages and questions:          patch Messages.      (line   6)
5121 * patch options:                         patch Options.       (line   6)
5122 * patch producer tips:                   Tips for Patch Producers.
5123                                                               (line   6)
5124 * patch, common mistakes:                Avoiding Common Mistakes.
5125                                                               (line   6)
5126 * patches, shrinking:                    Generating Smaller Patches.
5127                                                               (line   6)
5128 * patching directories:                  patch Directories.   (line   6)
5129 * PATCH_GET:                             Revision Control.    (line  13)
5130 * PATCH_VERSION_CONTROL:                 Backup Names.        (line  21)
5131 * pebibyte, definition of:               cmp Options.         (line  97)
5132 * performance of diff:                   diff Performance.    (line   6)
5133 * petabyte, definition of:               cmp Options.         (line  94)
5134 * POSIX:                                 patch and POSIX.     (line   6)
5135 * POSIX <1>:                             Standards conformance.
5136                                                               (line   6)
5137 * POSIXLY_CORRECT:                       patch and POSIX.     (line   6)
5138 * POSIXLY_CORRECT <1>:                   Standards conformance.
5139                                                               (line   6)
5140 * projects for directories:              Shortcomings.        (line   6)
5141 * quoting style:                         patch Quoting Style. (line   6)
5142 * QUOTING_STYLE:                         patch Quoting Style. (line  26)
5143 * RCS:                                   Revision Control.    (line   6)
5144 * RCS script output format:              RCS.                 (line   6)
5145 * regular expression matching headings:  Specified Headings.  (line   6)
5146 * regular expression suppression:        Specified Lines.     (line   6)
5147 * reject file names:                     Reject Names.        (line   6)
5148 * removing empty files:                  Creating and Removing.
5149                                                               (line   6)
5150 * reporting bugs:                        Bugs.                (line   6)
5151 * reversed patches:                      Reversed Patches.    (line   6)
5152 * revision control:                      Revision Control.    (line   6)
5153 * sample input for diff:                 Sample diff Input.   (line   6)
5154 * sample input for diff3:                Sample diff3 Input.  (line   6)
5155 * SCCS:                                  Revision Control.    (line   6)
5156 * script output formats:                 Scripts.             (line   6)
5157 * sdiff invocation:                      Invoking sdiff.      (line   6)
5158 * sdiff options:                         sdiff Options.       (line   6)
5159 * sdiff output format:                   sdiff Option Summary.
5160                                                               (line   6)
5161 * section headings:                      Sections.            (line   6)
5162 * side by side:                          Side by Side.        (line   6)
5163 * side by side format:                   Side by Side Format. (line   6)
5164 * SIMPLE_BACKUP_SUFFIX:                  Backup Names.        (line  12)
5165 * special files:                         Special Files.       (line   6)
5166 * specified headings:                    Specified Headings.  (line   6)
5167 * summarizing which files differ:        Brief.               (line   6)
5168 * System V diff3 compatibility:          Saving the Changed File.
5169                                                               (line   6)
5170 * tab and blank difference suppression:  White Space.         (line   6)
5171 * tab stop alignment:                    Tabs.                (line   6)
5172 * tebibyte, definition of:               cmp Options.         (line  92)
5173 * terabyte, definition of:               cmp Options.         (line  89)
5174 * terminal, using color iff:             diff Options.        (line  42)
5175 * testing patch:                         Dry Runs.            (line   6)
5176 * text versus binary diff:               Binary.              (line   6)
5177 * timestamp format, context diffs:       Detailed Context.    (line  12)
5178 * timestamp format, unified diffs:       Detailed Unified.    (line  12)
5179 * timestamps on patched files:           Patching Timestamps. (line   6)
5180 * traditional patch:                     patch and Tradition. (line   6)
5181 * trailing blanks:                       Trailing Blanks.     (line   6)
5182 * two-column output:                     Side by Side.        (line   6)
5183 * unified output format:                 Unified Format.      (line   6)
5184 * unmerged change:                       Which Changes.       (line   6)
5185 * varying-width characters:              Internationalization.
5186                                                               (line   6)
5187 * verbose messages from patch:           More or Fewer Messages.
5188                                                               (line   6)
5189 * version control:                       Revision Control.    (line   6)
5190 * VERSION_CONTROL:                       Revision Control.    (line  22)
5191 * VERSION_CONTROL <1>:                   Backup Names.        (line  21)
5192 * white space in patches:                Changed White Space. (line   6)
5193 * yottabyte, definition of:              cmp Options.         (line 110)
5194 * zettabyte, definition of:              cmp Options.         (line 104)
5195
5196
5197 \1f
5198 Tag Table:
5199 Node: Top\7f1431
5200 Node: Overview\7f3644
5201 Node: Comparison\7f7398
5202 Node: Hunks\7f10340
5203 Node: White Space\7f11781
5204 Node: Blank Lines\7f13620
5205 Node: Specified Lines\7f14609
5206 Node: Case Folding\7f15735
5207 Node: Brief\7f16152
5208 Node: Binary\7f17475
5209 Node: Output Formats\7f21272
5210 Node: Sample diff Input\7f21997
5211 Node: Context\7f23496
5212 Node: Context Format\7f25073
5213 Node: Example Context\7f25865
5214 Node: Less Context\7f27372
5215 Node: Detailed Context\7f28561
5216 Node: Unified Format\7f30756
5217 Node: Example Unified\7f31565
5218 Node: Detailed Unified\7f32603
5219 Node: Sections\7f34243
5220 Node: Specified Headings\7f35002
5221 Node: C Function Headings\7f36551
5222 Node: Alternate Names\7f37397
5223 Node: Side by Side\7f38310
5224 Node: Side by Side Format\7f40460
5225 Node: Example Side by Side\7f41362
5226 Node: Normal\7f42702
5227 Node: Example Normal\7f43703
5228 Node: Detailed Normal\7f44439
5229 Node: Scripts\7f46178
5230 Node: ed Scripts\7f46583
5231 Node: Example ed\7f47789
5232 Node: Detailed ed\7f48239
5233 Node: Forward ed\7f49998
5234 Node: RCS\7f50774
5235 Node: If-then-else\7f51990
5236 Node: Line Group Formats\7f53668
5237 Node: Line Formats\7f59549
5238 Node: Example If-then-else\7f62818
5239 Node: Detailed If-then-else\7f63897
5240 Node: Incomplete Lines\7f65782
5241 Node: Comparing Directories\7f67418
5242 Node: Adjusting Output\7f71619
5243 Node: Tabs\7f72126
5244 Node: Trailing Blanks\7f73740
5245 Node: Pagination\7f74965
5246 Node: diff Performance\7f75433
5247 Node: Comparing Three Files\7f78522
5248 Node: Sample diff3 Input\7f79400
5249 Node: Example diff3 Normal\7f80348
5250 Node: Detailed diff3 Normal\7f81408
5251 Node: diff3 Hunks\7f83196
5252 Node: diff3 Merging\7f84462
5253 Node: Which Changes\7f86707
5254 Node: Marking Conflicts\7f88107
5255 Node: Bypassing ed\7f90562
5256 Node: Merging Incomplete Lines\7f91905
5257 Node: Saving the Changed File\7f92631
5258 Node: Interactive Merging\7f93247
5259 Node: sdiff Option Summary\7f93956
5260 Node: Merge Commands\7f95159
5261 Node: Merging with patch\7f96448
5262 Node: patch Input\7f98815
5263 Node: Revision Control\7f99497
5264 Node: Imperfect\7f100667
5265 Node: Changed White Space\7f101816
5266 Node: Reversed Patches\7f102613
5267 Node: Inexact\7f104077
5268 Node: Dry Runs\7f107633
5269 Node: Creating and Removing\7f108497
5270 Node: Patching Timestamps\7f109546
5271 Node: Multiple Patches\7f111733
5272 Node: patch Directories\7f114394
5273 Node: Backups\7f116018
5274 Node: Backup Names\7f117082
5275 Ref: Backup Names-Footnote-1\7f120037
5276 Node: Reject Names\7f120164
5277 Node: patch Messages\7f120753
5278 Node: More or Fewer Messages\7f121813
5279 Node: patch and Keyboard Input\7f122444
5280 Node: patch Quoting Style\7f123473
5281 Node: patch and POSIX\7f124619
5282 Node: patch and Tradition\7f125458
5283 Node: Making Patches\7f128879
5284 Node: Tips for Patch Producers\7f129705
5285 Node: Tips for Patch Consumers\7f130960
5286 Node: Avoiding Common Mistakes\7f131597
5287 Node: Generating Smaller Patches\7f134122
5288 Node: Invoking cmp\7f135881
5289 Node: cmp Options\7f137431
5290 Node: Invoking diff\7f141075
5291 Node: diff Options\7f142694
5292 Node: Invoking diff3\7f152543
5293 Node: diff3 Options\7f153181
5294 Node: Invoking patch\7f156214
5295 Node: patch Options\7f157422
5296 Node: Invoking sdiff\7f162642
5297 Node: sdiff Options\7f163784
5298 Node: Standards conformance\7f166756
5299 Node: Projects\7f168502
5300 Node: Shortcomings\7f169214
5301 Node: Internationalization\7f170314
5302 Node: Changing Structure\7f171480
5303 Node: Special Files\7f172583
5304 Node: Unusual File Names\7f173694
5305 Node: Timestamp Order\7f174332
5306 Node: Ignoring Changes\7f174968
5307 Node: Speedups\7f175737
5308 Node: Bugs\7f176199
5309 Node: Copying This Manual\7f177052
5310 Node: Translations\7f202173
5311 Node: Index\7f202545
5312 \1f
5313 End Tag Table
5314
5315 \1f
5316 Local Variables:
5317 coding: utf-8
5318 End: