Debian Codegraph @

doc/diffutils.info

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