Lines Matching full:command

13 and documents the @acronym{GNU} @command{diff}, @command{diff3},
14 @command{sdiff}, and @command{cmp} commands for showing the
15 differences between files and the @acronym{GNU} @command{patch} command for
79 * Adjusting Output:: Making @command{diff} output prettier.
80 * diff Performance:: Making @command{diff} smarter or faster.
85 * Interactive Merging:: Interactive merging with @command{sdiff}.
87 * Merging with patch:: Using @command{patch} to change old files into new ones.
106 @cindex overview of @command{diff} and @command{patch}
112 You can use the @command{diff} command to show differences between two
113 files, or each corresponding file in two directories. @command{diff}
115 formats, selectable by command line options. This set of differences is
117 @command{diff} normally produces no output; for binary (non-text) files,
118 @command{diff} normally reports only that they are different.
120 You can use the @command{cmp} command to show the byte and line numbers
121 where two files differ. @command{cmp} can also show all the bytes
123 two files character by character is the Emacs command @kbd{M-x
125 Emacs Manual}, for more information on that command.
127 You can use the @command{diff3} command to show differences among three
129 original, @command{diff3} can report the differences between the original
133 You can use the @command{sdiff} command to merge two files interactively.
135 You can use the set of differences produced by @command{diff} to distribute
138 to the complete files. Given @command{diff} output, you can use the
139 @command{patch} program to update, or @dfn{patch}, a copy of the file. If you
140 think of @command{diff} as subtracting one file from another to produce
141 their difference, you can think of @command{patch} as adding the difference
147 @acronym{GNU} @command{diff} was written by Paul Eggert, Mike Haertel,
167 Unless the @option{--minimal} option is used, @command{diff} uses a
176 @acronym{GNU} @command{diff3} was written by Randy Smith. @acronym{GNU}
177 @command{sdiff} was written by Thomas Lord. @acronym{GNU} @command{cmp}
180 @acronym{GNU} @command{patch} was written mainly by Larry Wall and Paul Eggert;
192 file. @command{diff} compares two files line by line, finds groups of
197 @acronym{GNU} @command{diff} can show whether files are different
201 between words or lines. @command{diff} also provides ways to suppress
209 different. @command{cmp} reports the differences between two files
211 more useful than @command{diff} for comparing binary files. For text
212 files, @command{cmp} is useful mainly when you want to know only whether
219 that lacks the newline at the beginning, @command{diff} will report that a
220 blank line has been added to the file, while @command{cmp} will report that
223 @command{diff3} normally compares three input files line by line, finds
242 When comparing two files, @command{diff} finds sequences of lines common to
248 match up lines between two given files. @command{diff} tries to minimize
255 @command{diff} finds the line @samp{c} as common, then the command
268 But if @command{diff} notices the common line @samp{b} instead, it produces
283 It is also possible to find @samp{a} as the common line. @command{diff}
301 option, @command{diff} considers the following two lines to be equivalent,
314 With this option, @command{diff} considers the
359 @command{grep}-style regular expression, use the @option{-I
369 words, for each nonignorable change, @command{diff} prints the complete set
373 using more than one @option{-I} option. @command{diff} tries to match each
380 @acronym{GNU} @command{diff} can treat lower case letters as
394 files, @command{diff} simply reports whether files differ. The @option{-q}
399 comparisons, because @command{diff} can stop analyzing the files as soon as
403 @command{cmp}. For files that are identical, @command{cmp} produces no
404 output. When the files differ, by default, @command{cmp} outputs the byte
408 suppress that information, so that @command{cmp}
413 Unlike @command{diff}, @command{cmp} cannot compare directories; it can only
421 If @command{diff} thinks that either of the two files it is comparing is
427 @command{diff} determines whether a file is text or binary by checking the
430 that part of the file is non-null, @command{diff} considers the file to be
433 Sometimes you might want to force @command{diff} to consider files to be
435 null characters; @command{diff} would erroneously decide that those are
438 indicate special formatting. You can force @command{diff} to consider all
442 newline characters, and the @command{diff} output will consist of hunks
446 You can also force @command{diff} to report only whether files differ
451 resulting @command{diff} output does not capture all the differences.
452 This trouble causes @command{diff} to exit with status 2. However,
455 options both cause @command{diff} to generate a form of output that
459 @command{diff} normally reads and writes all data as text. Use the
460 @option{--binary} option to force @command{diff} to read and write binary
464 followed by a newline. On such systems, @command{diff} normally ignores
466 output line, but with the @option{--binary} option @command{diff} treats
472 The @option{--strip-trailing-cr} causes @command{diff} to treat input
480 @command{cmp} program with the @option{-l} or @option{--verbose}
482 With @acronym{GNU} @command{cmp}, you can also use the @option{-b} or
486 If @command{diff3} thinks that any of the files it is comparing is binary
488 comparisons are usually not useful. @command{diff3} uses the same test as
489 @command{diff} to decide whether a file is binary. As with @command{diff}, if
491 text files, you can force @command{diff3} to consider all files to be text
496 @chapter @command{diff} Output Formats
498 @cindex format of @command{diff} output
500 @command{diff} has several mutually exclusive options for output format.
502 @command{diff} reports the differences between two sample input files.
505 * Sample diff Input:: Sample @command{diff} input files for examples.
515 @cindex @command{diff} sample input
516 @cindex sample input for @command{diff}
519 illustrate the output of @command{diff} and how various options can change
571 @acronym{GNU} @command{diff} provides two output formats that show context
577 form of @command{diff} output, you should use one of the output formats
579 made small changes of their own to the files. @command{patch} can apply
582 lines away from where the diff says they are, @command{patch} can adjust
584 @xref{Imperfect}, for more information on using @command{patch} to apply
605 defaults to three. For proper operation, @command{patch} typically needs
762 At present, only @acronym{GNU} @command{diff} can produce this format and
763 only @acronym{GNU} @command{patch} can automatically apply diffs in this
764 format. For proper operation, @command{patch} typically needs at
775 Here is the output of the command @samp{diff -u lao tzu}
859 chapter or appendix was changed. @acronym{GNU} @command{diff} can
876 or @option{--show-function-line=@var{regexp}} option. @command{diff}
877 considers lines that match the @command{grep}-style regular expression
904 regular expression for such lines; @command{diff} tries to match each line
918 command line. You can override both the format and the number with
919 @option{-U @var{lines}} elsewhere in the command line.
924 @command{diff} provides this option for the sake of convenience.
932 names, you might want @command{diff} to show alternate names in the header
938 twice, @command{diff} reports an error. The @option{--label} option does not
939 affect the file names in the @command{pr} header when the @option{-l} or
956 @command{diff} can produce a side by side difference listing of two files.
1002 You can use the @command{sdiff} command to interactively merge side by side
1031 Here is the output of the command @samp{diff -y -W 72 lao tzu}
1057 The ``normal'' @command{diff} output format shows each hunk of differences
1065 compatibility with older versions of @command{diff} and the @acronym{POSIX}
1077 Here is the output of the command @samp{diff lao tzu}
1105 @var{change-command}
1146 Several output modes produce command scripts for editing @var{from-file}
1150 * ed Scripts:: Using @command{diff} to produce commands for @command{ed}.
1151 * Forward ed:: Making forward @command{ed} scripts.
1152 * RCS:: A special @command{diff} output format used by @acronym{RCS}.
1156 @subsection @command{ed} Scripts
1157 @cindex @command{ed} script output format
1159 @command{diff} can produce commands that direct the @command{ed} text editor
1162 automatically; today, with @command{patch}, it is almost obsolete. Use the
1171 the command @samp{(cat d && echo w) | ed - old} edits @file{old} to make
1175 respectively, then the command @samp{(cat d1 d2 @dots{} dN && echo w) |
1179 * Example ed:: A sample @command{ed} script.
1180 * Detailed ed:: A detailed description of @command{ed} format.
1184 @subsubsection Example @command{ed} Script
1203 @subsubsection Detailed Description of @command{ed} Format
1205 The @command{ed} output format consists of one or more hunks of
1208 @command{ed} interprets line numbers in succeeding commands. @command{ed}
1212 @var{change-command}
1218 Because @command{ed} uses a single period on a line to indicate the
1219 end of input, @acronym{GNU} @command{diff} protects lines of changes
1221 then writing a subsequent @command{ed} command to change the two
1222 periods into one. The @command{ed} format cannot represent an
1224 line, @command{diff} reports an error and then pretends that a newline
1251 @subsection Forward @command{ed} Scripts
1252 @cindex forward @command{ed} script output format
1254 @command{diff} can produce output that is like an @command{ed} script, but
1256 is also changed slightly: command characters precede the lines they
1259 @command{ed} format, forward @command{ed} format cannot represent incomplete
1262 Forward @command{ed} format is not very useful, because neither @command{ed}
1263 nor @command{patch} can apply diffs in this format. It exists mainly for
1264 compatibility with older versions of @command{diff}. Use the @option{-f} or
1275 is like the forward @command{ed} format (@pxref{Forward ed}), but it
1277 avoids the forward @command{ed} format's problems with lines
1280 command specifies the number of lines it affects; a combination of the
1305 @cindex @command{ifdef} output format
1307 You can use @command{diff} to merge two files of C source code. The output
1308 of @command{diff} in this format contains all the lines of both files.
1315 To merge two files, use @command{diff} with the @option{-D @var{name}} or
1356 For example, the following command compares the TeX files @file{old}
1372 The following command is equivalent to the above example, but it is a
1408 To specify a line group format, use @command{diff} with one of the options
1528 For example, the following command outputs text with a one-character
1608 different formats. For example, the following command uses a format
1609 similar to normal @command{diff} format. You can tailor this command
1610 to get fine control over @command{diff} output.
1664 For lines common to both files, @command{diff} uses the unchanged line
1667 @command{diff} uses the old line group format; if the hunk contains only
1668 lines from the second file, @command{diff} uses the new group format;
1669 otherwise, @command{diff} uses the changed group format.
1692 You should carefully check the @command{diff} output for proper nesting.
1703 The @command{patch} @option{-D @var{name}} option behaves like
1704 the @command{diff} @option{-D @var{name}} option, except it operates on
1711 @cindex newline treatment by @command{diff}
1727 Formats}. Finally, with the @command{ed} and forward @command{ed}
1728 output formats (@pxref{Output Formats}) @command{diff} cannot
1768 You can use @command{diff} to compare some or all of the files in two
1769 directory trees. When both file name arguments to @command{diff} are
1773 @command{diff} is silent about pairs of files that contain no differences,
1775 it reports pairs of identical files. Normally @command{diff} reports
1781 For file names that are in only one of the directories, @command{diff}
1784 can make @command{diff} act as though the file existed but was empty in the
1826 one directory and upper case in the upper, @command{diff} normally
1829 @command{diff} ignores case differences in file names, so that for example
1844 @chapter Making @command{diff} Output Prettier
1846 @command{diff} provides several ways to adjust the appearance of its output.
1851 * Pagination:: Page numbering and time-stamping @command{diff} output.
1859 The lines of text in some of the @command{diff} output formats are
1863 columns in the line. @acronym{GNU} @command{diff} provides two ways
1866 The first way is to have @command{diff} convert all tabs into the correct
1869 @command{patch}, you must give @command{patch} the @option{-l} or
1871 information). @command{diff} normally assumes that tab stops are set
1887 @section Paginating @command{diff} Output
1888 @cindex paginating @command{diff} output
1892 @command{diff} output through the @command{pr} program. Here is what the page
1900 @chapter @command{diff} Performance Tradeoffs
1901 @cindex performance of @command{diff}
1903 @acronym{GNU} @command{diff} runs quite efficiently; however, in some
1907 One way to improve @command{diff} performance is to use hard or
1909 because @command{diff} normally does not need to read two hard or
1919 You can also affect the performance of @acronym{GNU} @command{diff} by
1925 The way that @acronym{GNU} @command{diff} determines which lines have
1928 @command{diff} output is large, you might want @command{diff} to use a
1931 however, it can also cause @command{diff} to run more slowly than
1937 the algorithm that @command{diff} uses. If the input files have a constant
1939 changing the output. If not, @command{diff} might produce a larger set of
1942 Normally @command{diff} discards the prefix and suffix that is common to
1944 This makes @command{diff} run faster, but occasionally it may produce
1946 prevents @command{diff} from discarding the last @var{lines} lines of the
1948 @command{diff} further opportunities to find a minimal output.
1952 The @command{diff} command is free to choose which identical sequence is
1953 included in the hunk. In this case, @command{diff} normally shifts the
1961 @cindex format of @command{diff3} output
1963 Use the program @command{diff3} to compare three files and show any
1964 differences among them. (@command{diff3} can also merge files; see
1967 The ``normal'' @command{diff3} output format shows each hunk of
1972 @xref{Invoking diff3}, for more information on how to run @command{diff3}.
1975 * Sample diff3 Input:: Sample @command{diff3} input for examples.
1983 @cindex @command{diff3} sample input
1984 @cindex sample input for @command{diff3}
1987 the output of @command{diff3} and how various options can change it. The
1988 first two files are the same that we used for @command{diff} (@pxref{Sample
2009 @section An Example of @command{diff3} Normal Format
2011 Here is the output of the command @samp{diff3 lao tzu tao}
2048 @section Detailed Description of @command{diff3} Normal Format
2059 option, @command{diff3} uses a tab instead of two spaces; this lines up
2086 @section @command{diff3} Hunks
2087 @cindex hunks for @command{diff3}
2088 @cindex @command{diff3} hunks
2091 called @dfn{diff3 hunks}, by analogy with @command{diff} hunks
2092 (@pxref{Hunks}). If all three input files differ in a @command{diff3}
2096 As with @command{diff}, several solutions are possible. When comparing the
2097 files @samp{A}, @samp{B}, and @samp{C}, @command{diff3} normally finds
2098 @command{diff3} hunks by merging the two-way hunks output by the two
2134 @command{diff3} can produce a merged output that contains both sets of
2137 One might imagine programs with names like @command{diff4} and @command{diff5}
2139 need rarely arises. You can use @command{diff3} to merge three or more
2142 @command{diff3} can incorporate changes from two modified versions into a
2167 @command{diff3} gives you several ways to handle overlaps and conflicts.
2171 @command{diff3} can output the merge results as an @command{ed} script that
2173 However, it is usually better to have @command{diff3} generate the merged
2174 output directly; this bypasses some problems with @command{ed}.
2180 * Merging Incomplete Lines:: How @command{diff3} merges incomplete lines.
2203 Here is the output of the command @command{diff3} with each of these three
2239 @command{diff3} can mark conflicts in the merged output by
2323 @cindex merged @command{diff3} format
2325 With the @option{-m} or @option{--merge} option, @command{diff3} outputs the
2326 merged file directly. This is more efficient than using @command{ed} to
2327 generate it, and works even with non-text files that @command{ed} would
2328 reject. If you specify @option{-m} without an @command{ed} script option,
2331 For example, the command @samp{diff3 -m lao tzu tao}
2362 @section How @command{diff3} Merges Incomplete Lines
2372 Without @option{-m}, if an @command{ed} script option is specified and an
2373 incomplete line is found, @command{diff3} generates a warning and acts as
2378 @cindex System V @command{diff3} compatibility
2380 Traditional Unix @command{diff3} generates an @command{ed} script without the
2382 System V @command{diff3} generates these extra commands. @acronym{GNU}
2383 @command{diff3} normally behaves like traditional Unix
2384 @command{diff3}, but with the @option{-i} option it behaves like
2385 System V @command{diff3} and appends the @samp{w} and @samp{q}
2388 The @option{-i} option requires one of the @command{ed} script options
2393 @chapter Interactive Merging with @command{sdiff}
2397 With @command{sdiff}, you can merge two files interactively based on a
2401 options to @command{sdiff}.
2404 package @command{emerge}. @xref{emerge, , emerge, emacs, The
2408 * sdiff Option Summary:: Summary of @command{sdiff} options.
2413 @section Specifying @command{diff} Options to @command{sdiff}
2414 @cindex @command{sdiff} output format
2416 The following @command{sdiff} options have the same meaning as for
2417 @command{diff}. @xref{diff Options}, for the use of these options.
2432 For historical reasons, @command{sdiff} has alternate names for some
2435 to @option{--suppress-common-lines}. The meaning of the @command{sdiff}
2437 @command{diff}: with @command{sdiff}, @option{-w @var{columns}} is
2439 equivalent to @option{--ignore-all-space}. @command{sdiff} without the
2440 @option{-o} option is equivalent to @command{diff} with the @option{-y}
2449 file to the output. After each group of differing lines, @command{sdiff}
2451 commands. Follow each command with @key{RET}.
2498 @chapter Merging with @command{patch}
2500 @command{patch} takes comparison output produced by @command{diff} and applies
2502 version. With @command{patch}, you can distribute just the changes to a
2504 correspondents can apply @command{patch} to update their copy of the files
2505 with your changes. @command{patch} automatically determines the diff
2509 @command{patch}.
2511 @command{patch} detects and warns about common problems like forward
2516 @command{patch} accepts a series of diffs in its standard input, usually
2518 @command{diff} hunks (@pxref{Hunks}) one by one. If a hunk does not
2519 exactly match the original file, @command{patch} uses heuristics to try to
2521 @command{patch} rejects the hunk and skips to the next hunk. @command{patch}
2526 @command{patch}.
2529 * patch Input:: Selecting the type of @command{patch} input.
2539 * patch Messages:: Messages and questions @command{patch} can produce.
2541 * patch and Tradition:: @acronym{GNU} versus traditional @command{patch}.
2545 @section Selecting the @command{patch} Input Format
2546 @cindex @command{patch} input format
2548 @command{patch} normally determines which @command{diff} format the patch
2551 following options to force @command{patch} to interpret the patch file as a
2553 ones that @command{patch} can understand.
2562 @command{ed} script.
2582 supported by @command{patch}, @command{patch} normally asks the user
2586 @command{patch} also asks when the input file is read-only and matches
2592 positive, @command{patch} gets the file without asking the user; if
2593 zero, @command{patch} neither asks the user nor gets the file; and if
2594 negative, @command{patch} asks the user before getting the file. The
2597 value is zero if @command{patch} is conforming to @acronym{POSIX}, negative
2608 @command{patch} tries to skip any leading text in the patch file,
2610 mail message directly to @command{patch}, and it should work. If the
2612 @command{patch} automatically ignores the indentation. If a context
2613 diff contains trailing carriage return on each line, @command{patch}
2617 @command{patch} automatically unencapsulates the input.
2625 * Inexact:: Helping @command{patch} find close matches.
2626 * Dry Runs:: Predicting what @command{patch} will do.
2635 files might look the same, but @command{patch} will not be able to match
2637 @option{--ignore-white-space} option, which makes @command{patch} compare
2648 Sometimes people run @command{diff} with the new file first instead of
2650 patches, give @command{patch} the @option{-R} or @option{--reverse} option.
2651 @command{patch} then attempts to swap each hunk around before applying it.
2654 Often @command{patch} can guess that the patch is reversed. If the first
2655 hunk of a patch fails, @command{patch} reverses the hunk to see if it can
2656 apply it that way. If it can, @command{patch} asks you if you want to have
2657 the @option{-R} option set; if it can't, @command{patch} continues to apply
2659 a normal diff and the first command is an append (which should have been
2663 @command{patch} notices.
2665 If you apply a patch that you have already applied, @command{patch} thinks
2670 @command{patch} process.
2673 @subsection Helping @command{patch} Find Inexact Matches
2677 For context diffs, and to a lesser extent normal diffs, @command{patch} can
2682 the correct place, @command{patch} scans both forward and backward for a
2685 First @command{patch} looks for a place where all lines of the context
2688 @command{patch} makes another scan, ignoring the first and last line of
2702 If @command{patch} cannot find a place to install a hunk of the patch, it
2706 normal or @command{ed} diff, many of the contexts are simply null. The
2708 in the patch file: they show the approximate location where @command{patch}
2713 as it completes each hunk @command{patch} tells you whether the hunk
2715 @command{patch} thinks the hunk should go. If this is different from the
2717 large offset @emph{may} indicate that @command{patch} installed a hunk in
2718 the wrong place. @command{patch} also tells you if it used a fuzz factor
2721 @command{patch} cannot tell if the line numbers are off in an @command{ed}
2723 finds a change or delete command. It may have the same problem with a
2733 @command{patch} usually produces the correct results, even when it must
2739 @subsection Predicting what @command{patch} will do
2740 @cindex testing @command{patch}
2741 @cindex dry runs for @command{patch}
2743 It may not be obvious in advance what @command{patch} will do with a
2745 input might cause @command{patch} to modify the wrong files, you can
2746 use the @option{--dry-run} option, which causes @command{patch} to
2749 to see whether @command{patch} will modify the files that you expect.
2751 the other options to @command{patch}) and try another dry run. Once
2753 @command{patch} as before, but this time without the
2763 directory but not the other. If you give @command{diff} the
2766 Epoch (1970-01-01 00:00:00 UTC), @command{diff} outputs a patch that
2768 @command{patch} normally creates a new file or removes the old file.
2770 @command{patch} does not remove the old file, but leaves it empty.
2772 @command{patch} to remove output files that are empty after applying a
2777 @command{patch} asks for confirmation before applying the patch.
2783 When @command{patch} updates a file, it normally sets the file's
2785 @command{patch} to track a software distribution, this can cause
2786 @command{make} to incorrectly conclude that a patched file is out of
2788 @command{patch} updates @file{syntax.c} and then @file{syntax.y}, then
2792 The @option{-Z} or @option{--set-utc} option causes @command{patch} to
2807 @command{patch} normally refrains from setting a file's time stamps if
2813 Due to the limitations of the current @command{diff} format,
2814 @command{patch} cannot update the times of files whose contents have
2818 invocations of @command{make} do not get confused by the patched
2827 specify an input file on the command line, @command{patch} tries to
2834 @command{patch} uses the following rules to intuit a file name from
2835 the leading text before a patch. First, @command{patch} takes an
2840 If the header is that of a context diff, @command{patch} takes the old
2848 the old and new names are both absent or if @command{patch} is
2849 conforming to @acronym{POSIX}, @command{patch} takes the name in the
2859 Then @command{patch} selects a file name from the candidate list as
2864 If some of the named files exist, @command{patch} selects the first
2868 If @command{patch} is not ignoring @acronym{RCS}, ClearCase, and @acronym{SCCS}
2870 ClearCase, or @acronym{SCCS} master is found, @command{patch} selects the
2875 was found, some names are given, @command{patch} is not conforming to
2876 @acronym{POSIX}, and the patch appears to create a file, @command{patch}
2882 the name of the file to patch, and @command{patch} selects that name.
2886 @command{patch} first takes all the names with the fewest path name
2891 @xref{patch and POSIX}, to see whether @command{patch} is conforming
2900 option to @command{patch} makes directory @var{directory} the current
2916 count tells @command{patch} how many slashes, along with the directory
2919 default, @command{patch} strips off all leading directories, leaving
2928 @command{patch} looks for each file (after any slashes have been stripped)
2936 Normally, @command{patch} creates a backup file if the patch does not
2940 to @acronym{POSIX}, @command{patch} does not create backup files by
2943 The @option{-b} or @option{--backup} option causes @command{patch} to
2946 @command{patch} to create backup files for mismatches files; this is
2948 @option{--no-backup-if-mismatch} option causes @command{patch} to not
2960 Normally, @command{patch} renames an original input file into a backup
2963 long.@footnote{A coding error in @acronym{GNU} @command{patch} version
2966 @option{--suffix=@var{backup-suffix}} option causes @command{patch} to
2974 @command{patch} can also create numbered backup files the way
2976 single backup of each file, @command{patch} makes a new backup file
2986 control the type of backups that @command{patch} makes with the
3016 You can also tell @command{patch} to prepend a prefix, such as a
3039 @command{patch} could not find a place to apply) are normally the name
3043 Alternatively, you can tell @command{patch} to place all of the rejected
3049 @section Messages and Questions from @command{patch}
3050 @cindex @command{patch} messages and questions
3051 @cindex diagnostics from @command{patch}
3052 @cindex messages from @command{patch}
3054 @command{patch} can produce a variety of messages, especially if it
3056 sure how to proceed, @command{patch} normally prompts you for more
3062 * More or Fewer Messages:: Controlling the verbosity of @command{patch}.
3067 @command{patch} exits with status 0 if all hunks are applied successfully,
3074 @subsection Controlling the Verbosity of @command{patch}
3075 @cindex verbose messages from @command{patch}
3076 @cindex inhibit messages from @command{patch}
3078 You can cause @command{patch} to produce more messages by using the
3080 the message @samp{Hmm...} indicates that @command{patch} is reading text in
3084 You can inhibit all terminal output from @command{patch}, unless an error
3090 @cindex keyboard input to @command{patch}
3092 There are two ways you can prevent @command{patch} from asking you any
3094 what you are doing. It causes @command{patch} to do the following:
3126 @subsection @command{patch} Quoting Style
3129 When @command{patch} outputs a file name in a diagnostic message, it
3163 but this default may change in a future version of @command{patch}.
3166 @section @command{patch} and the @acronym{POSIX} Standard
3171 @env{POSIXLY_CORRECT} environment variable, @command{patch} conforms
3188 Require that all options precede the files in the command line.
3196 @section @acronym{GNU} @command{patch} and Traditional @command{patch}
3197 @cindex traditional @command{patch}
3199 The current version of @acronym{GNU} @command{patch} normally follows the
3203 Unfortunately, @acronym{POSIX} redefined the behavior of @command{patch} in
3205 differences if you must interoperate with traditional @command{patch},
3206 or with @acronym{GNU} @command{patch} version 2.1 and earlier.
3210 In traditional @command{patch}, the @option{-p} option's operand was
3216 Also, traditional @command{patch} simply counted slashes when
3217 stripping path prefixes; @command{patch} now counts pathname
3223 In traditional @command{patch}, backups were enabled by default. This
3227 Conversely, in @acronym{POSIX} @command{patch}, backups are never made,
3228 even when there is a mismatch. In @acronym{GNU} @command{patch}, this
3232 The @option{-b@ @var{suffix}} option of traditional @command{patch} is
3234 @command{patch}.
3237 Traditional @command{patch} used a complicated (and incompletely
3240 a few gotchas. Now @command{patch} uses a different, equally
3249 When traditional @command{patch} asked the user a question, it sent
3253 @command{patch} sends questions to standard output and gets answers
3255 that @command{patch} never goes into an infinite loop when using
3259 Traditional @command{patch} exited with a status value that counted
3261 Now @command{patch} exits with status 1 if some hunks failed, or with
3266 meant to be executed by anyone running @acronym{GNU} @command{patch},
3267 traditional @command{patch}, or a @command{patch} that conforms to
3301 * Avoiding Common Mistakes:: Avoiding common mistakes when using @command{patch}.
3312 @command{tar} archives of the two versions.
3314 To generate the patch, use the command @samp{diff -Naur @var{old}
3320 the patch update subdirectories. Here is an example command, using
3328 which working directory to use, and which @command{patch} options to
3344 @acronym{GNU} @command{diff} can analyze files with arbitrarily long lines
3346 @command{patch} cannot patch such files. If you are having trouble
3348 @command{patch}.
3355 When producing a patch for multiple files, apply @command{diff} to
3370 different versions of @command{patch} interpret the file names
3387 @command{patch} into patching a backup file instead of the real file.
3395 the input file contains the wrong version number, @command{patch} will
3400 line that starts with @samp{Prereq:}, @command{patch} takes the next word
3403 white space or a newline. If not, @command{patch} prompts you for
3416 between the two versions, make a list of @command{rm} and @command{mv}
3423 @file{TAGS} and output from @command{yacc} and @command{makeinfo}),
3424 exclude them from the patch by giving @command{diff} the @option{-x
3429 stamps will not confuse @command{make}.
3434 Add to the top of the patch a note telling the user any @command{rm} and
3435 @command{mv} commands to run before applying the patch. Then you can
3439 but bear in mind that @command{patch} typically needs at least two
3444 @chapter Invoking @command{cmp}
3445 @cindex invoking @command{cmp}
3446 @cindex @command{cmp} invocation
3448 The @command{cmp} command compares two files, and if they differ,
3451 lines are numbered starting with 1. The arguments of @command{cmp}
3458 The file name @file{-} is always the standard input. @command{cmp}
3464 By default, @command{cmp} outputs nothing if the two files have the
3465 same contents. If one file is a prefix of the other, @command{cmp}
3472 Otherwise, @command{cmp} prints to standard output a message of the
3487 * cmp Options:: Summary of options to @command{cmp}.
3491 @section Options to @command{cmp}
3492 @cindex @command{cmp} options
3493 @cindex options for @command{cmp}
3496 @command{cmp} accepts. Most options have two equivalent names, one of
3499 (unless they take an argument) can be combined into a single command
3623 @chapter Invoking @command{diff}
3624 @cindex invoking @command{diff}
3625 @cindex @command{diff} invocation
3627 The format for running the @command{diff} command is:
3634 @var{to-file} are given, and @command{diff} compares the contents of
3639 If one file is a directory and the other is not, @command{diff} compares
3644 @command{diff} compares corresponding files in both directories, in
3646 @option{-r} or @option{--recursive} option is given. @command{diff} never
3657 @command{diff} options begin with @samp{-}, so normally file names
3669 * diff Options:: Summary of options to @command{diff}.
3673 @section Options to @command{diff}
3674 @cindex @command{diff} options
3675 @cindex options for @command{diff}
3678 @command{diff} accepts. Most options have two equivalent names, one
3682 command line word: @option{-ac} is equivalent to @option{-a -c}. Long
3712 For proper operation, @command{patch} typically needs at least two lines of
3715 On older systems, @command{diff} supports an obsolete option
3728 @command{diff} slower (sometimes much slower). @xref{diff Performance}.
3737 Make output that is a valid @command{ed} script. @xref{ed Scripts}.
3746 Make output that looks vaguely like an @command{ed} script but has changes
3782 Pass the output through @command{pr} to paginate it. @xref{Pagination}.
3799 Output @acronym{RCS}-format diffs; like @option{-f} except that each command
3898 For proper operation, @command{patch} typically needs at least two lines of
3901 On older systems, @command{diff} supports an obsolete option
3935 @chapter Invoking @command{diff3}
3936 @cindex invoking @command{diff3}
3937 @cindex @command{diff3} invocation
3939 The @command{diff3} command compares three files and outputs descriptions
3948 which tells @command{diff3} to read the standard input for that file.
3950 An exit status of 0 means @command{diff3} was successful, 1 means some
3954 * diff3 Options:: Summary of options to @command{diff3}.
3958 @section Options to @command{diff3}
3959 @cindex @command{diff3} options
3960 @cindex options for @command{diff3}
3962 Below is a summary of all of the options that @acronym{GNU} @command{diff3}
3964 can be combined into a single command line argument.
3980 instead of @command{diff}.
3984 Generate an @command{ed} script that incorporates all the changes from
4006 Generate @samp{w} and @samp{q} commands at the end of the @command{ed}
4024 output. Unlike piping the output from @command{diff3} to @command{ed}, this
4058 @chapter Invoking @command{patch}
4059 @cindex invoking @command{patch}
4060 @cindex @command{patch} invocation
4062 Normally @command{patch} is invoked like this:
4068 The full format for invoking @command{patch} is:
4077 @file{-}, @command{patch} reads the patch (that is, the @command{diff} output)
4080 If you do not specify an input file on the command line, @command{patch}
4082 that comes before the @command{diff} output) which file to edit.
4085 By default, @command{patch} replaces the original input file with the
4088 @command{patch} names backup files). You can also specify where to
4094 * patch Options:: Summary table of options to @command{patch}.
4098 @section Options to @command{patch}
4099 @cindex @command{patch} options
4100 @cindex options for @command{patch}
4102 Here is a summary of all of the options that @acronym{GNU} @command{patch}
4104 safe to use in older versions of @command{patch}.
4107 combined into a single command line argument with only one dash.
4151 Interpret the patch file as an @command{ed} script. @xref{patch Input}.
4192 Ignore patches that @command{patch} thinks are reversed or already applied.
4257 Set internal debugging flags. Of interest only to @command{patch}
4278 @chapter Invoking @command{sdiff}
4279 @cindex invoking @command{sdiff}
4280 @cindex @command{sdiff} invocation
4282 The @command{sdiff} command merges two files and interactively outputs the
4290 If @var{from-file} is a directory and @var{to-file} is not, @command{sdiff}
4295 @command{sdiff} options begin with @samp{-}, so normally @var{from-file}
4300 @command{sdiff} without @option{-o} (or @option{--output}) produces a
4302 or @option{--side-by-side} option of @command{diff} instead.
4308 * sdiff Options:: Summary of options to @command{diff}.
4312 @section Options to @command{sdiff}
4313 @cindex @command{sdiff} options
4314 @cindex options for @command{sdiff}
4317 @command{sdiff} accepts. Each option has two equivalent names, one of
4320 (unless they take an argument) can be combined into a single command
4342 makes @command{sdiff} slower (sometimes much slower). @xref{diff
4347 instead of @command{diff}.
4405 option is @option{-W} in @command{diff}, @option{-w} in @command{sdiff}.
4410 Note that for historical reasons, this option is @option{-w} in @command{diff},
4411 @option{-W} in @command{sdiff}.
4430 before operands, unless otherwise specified for a particular command.
4434 command @samp{diff -c -10} to have the same meaning as @samp{diff -C
4454 Here are some ideas for improving @acronym{GNU} @command{diff} and
4455 @command{patch}. The @acronym{GNU} project has identified some
4470 @section Suggested Projects for Improving @acronym{GNU} @command{diff} and @command{patch}
4473 One should be able to use @acronym{GNU} @command{diff} to generate a
4475 of one such tree, use @command{patch} to generate a faithful copy of
4477 expressed using current patch formats; also, @command{patch} does not
4496 @command{diff}, @command{diff3} and @command{sdiff} treat each line of
4499 @command{diff} does not properly ignore a multibyte space character.
4501 Also, @command{diff} currently assumes that each byte is one column
4504 @option{--side-by-side} option of @command{diff}.
4512 to support internationalized @command{diff}}.
4514 version of @command{diff}, so more work needs to be done in this area.
4520 @command{diff} and @command{patch} do not handle some changes to directory
4524 information for @command{patch} to transform the directory subtree into
4529 also be a way to tell @command{patch} that a file was renamed, even if
4530 there is no way for @command{diff} to generate such information.
4531 There should be a way to tell @command{patch} that a file's time stamp
4534 These problems can be fixed by extending the @command{diff} output format
4535 to represent changes in directory structure, and extending @command{patch}
4544 sockets. Currently, @command{diff} treats symbolic links as if they
4545 were the pointed-to files, except that a recursive @command{diff}
4547 symbolic links to @file{..}). @command{diff} treats other special
4550 that @command{patch} cannot represent changes to such files. For
4552 @command{diff} outputs the difference between the two files, instead
4557 @command{diff} should optionally report changes to special files specially,
4558 and @command{patch} should be extended to understand these extensions.
4565 white space, @samp{diff -r} generates a patch that @command{patch} cannot
4566 parse. The problem is with format of @command{diff} output, not just with
4567 @command{patch}, because with odd enough file names one can cause
4568 @command{diff} to generate a patch that is syntactically correct but
4569 patches the wrong files. The format of @command{diff} output should be
4575 Applying @command{patch} to a multiple-file diff can result in files
4576 whose time stamps are out of order. @acronym{GNU} @command{patch} has
4581 implement a @command{diff} option to output diffs in time stamp order.
4610 told @command{diff} to assume that two files with the same size and
4618 If you think you have found a bug in @acronym{GNU} @command{cmp},
4619 @command{diff}, @command{diff3}, or @command{sdiff}, please report it
4623 bug reports for @acronym{GNU} @command{patch} to