Lines Matching +full:dir +full:- +full:842

1 \input texinfo @c -*-texinfo-*-
25 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
26 and with the Back-Cover Texts as in (a) below. A copy of the
30 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
36 @c Debian install-info (up through at least version 1.9.20) uses only the
44 * sdiff: (diff)Invoking sdiff. Merge 2 files side-by-side.
76 * Output Formats:: Formats for two-way difference reports.
82 * Comparing Three Files:: Formats for three-way difference reports.
94 * Invoking sdiff:: Side-by-side merge of file differences.
117 @command{diff} normally produces no output; for binary (non-text) files,
123 two files character by character is the Emacs command @kbd{M-x
124 compare-windows}. @xref{Other Window, , Other Window, emacs, The @acronym{GNU}
151 @cite{Algorithmica} Vol.@: 1 No.@: 2, 1986, pp.@: 251--266; and in ``A File
153 @cite{Software---Practice and Experience} Vol.@: 15 No.@: 11, 1985,
154 pp.@: 1025--1040.
157 @c paper gives a rigorous treatment and the sub-algorithm for
162 @cite{Information and Control} Vol.@: 64, 1985, pp.@: 100--118.
167 Unless the @option{--minimal} option is used, @command{diff} uses a
174 1990, pp.@: 255--300.
274 ---
278 ---
287 @option{-d} or @option{--minimal} option (@pxref{diff Performance}).
294 The @option{-E} or @option{--ignore-tab-expansion} option ignores the
298 The @option{-b} or @option{--ignore-space-change} option is stronger.
305 Here lyeth muche rychnesse in lytell space. -- John Heywood$
306 Here lyeth muche rychnesse in lytell space. -- John Heywood $
309 The @option{-w} or @option{--ignore-all-space} option is stronger still.
319 Here lyeth muche rychnesse in lytell space.-- John Heywood$
320 He relyeth much erychnes seinly tells pace. --John Heywood ^M$
327 The @option{-B} or @option{--ignore-blank-lines} option ignores changes
334 -- Euclid, The Elements, I
343 -- Euclid, The Elements, I
347 if you also specify the @option{-b} or @option{--ignore-space-change}
348 option, or the @option{-w} or @option{--ignore-all-space} option,
350 In other words, @option{-B} is equivalent to @samp{-I '^$'} by
351 default, but it is equivalent to @option{-I '^[[:space:]]*$'} if
352 @option{-b} or @option{-w} is also specified.
359 @command{grep}-style regular expression, use the @option{-I
360 @var{regexp}} or @option{--ignore-matching-lines=@var{regexp}} option.
363 shell from expanding them. For example, @samp{diff -I '^[[:digit:]]'} ignores
366 However, @option{-I} only ignores the insertion or deletion of lines that
367 contain the regular expression if every changed line in the hunk---every
368 insertion and every deletion---matches the regular expression. In other
373 using more than one @option{-I} option. @command{diff} tries to match each
383 stuFf} to all be the same. To request this, use the @option{-i} or
384 @option{--ignore-case} option.
394 files, @command{diff} simply reports whether files differ. The @option{-q}
395 or @option{--brief} option selects this output format.
407 the @option{-s}, @option{--quiet}, or @option{--silent} option to
422 binary (a non-text file), it normally treats that pair of files much as
430 that part of the file is non-null, @command{diff} considers the file to be
436 non-text files. Or you might be comparing documents that are in a
440 @option{-a} or @option{--text} option. If the files you compare using this
447 (but not how). Use the @option{-q} or @option{--brief} option for
453 this trouble cannot occur with the @option{-a} or @option{--text}
454 option, or with the @option{-q} or @option{--brief} option, as these
460 @option{--binary} option to force @command{diff} to read and write binary
461 data instead. This option has no effect on a @acronym{POSIX}-compliant system
466 output line, but with the @option{--binary} option @command{diff} treats
469 useful when dealing with non-text files that are meant to be
470 interchanged with @acronym{POSIX}-compliant systems.
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
483 @option{--print-bytes} option to show the @acronym{ASCII} representation of
487 (a non-text file), it normally reports an error, because such
490 the input files contain a few non-text bytes but otherwise are like
492 files and compare them line by line by using the @option{-a} or
493 @option{--text} option.
510 * If-then-else:: Merging files with if-then-else.
529 Therefore let there always be non-being,
544 Therefore let there always be non-being,
601 To select this output format, use the @option{-C @var{lines}},
602 @option{--context@r{[}=@var{lines}@r{]}}, or @option{-c} option. The
617 Here is the output of @samp{diff -c lao tzu} (@pxref{Sample diff Input},
624 *** lao 2002-02-21 23:30:39.942229878 -0800
625 --- tzu 2002-02-21 23:30:50.442260588 -0800
628 - The Way that can be told of is not the eternal Way;
629 - The name that can be named is not the eternal name.
632 Therefore let there always be non-being,
635 --- 1,6 ----
639 Therefore let there always be non-being,
644 --- 8,13 ----
656 Here is the output of @samp{diff -C 1 lao tzu} (@pxref{Sample diff
661 *** lao 2002-02-21 23:30:39.942229878 -0800
662 --- tzu 2002-02-21 23:30:50.442260588 -0800
665 - The Way that can be told of is not the eternal Way;
666 - The name that can be named is not the eternal name.
669 Therefore let there always be non-being,
670 --- 1,4 ----
674 Therefore let there always be non-being,
677 --- 10,13 ----
687 The context output format starts with a two-line header, which looks
691 *** @var{from-file} @var{from-file-modification-time}
692 --- @var{to-file} @var{to-file-modification time}
698 The time stamp normally looks like @samp{2002-02-21 23:30:39.942229878
699 -0800} to indicate the date, time with fractional seconds, and time
700 zone in @uref{ftp://ftp.isi.edu/in-notes/rfc2822.txt, Internet RFC
707 @option{--label=@var{label}} option; see @ref{Alternate Names}.
714 *** @var{from-file-line-numbers} ****
715 @var{from-file-line}
716 @var{from-file-line}@dots{}
717 --- @var{to-file-line-numbers} ----
718 @var{to-file-line}
719 @var{to-file-line}@dots{}
741 @item -
747 @var{from-file} are omitted. If all of the changes are deletions, the
748 lines of @var{to-file} are omitted.
753 @cindex @samp{+-} output format
757 output format, use the @option{-U @var{lines}},
758 @option{--unified@r{[}=@var{lines}@r{]}}, or @option{-u}
775 Here is the output of the command @samp{diff -u lao tzu}
779 --- lao 2002-02-21 23:30:39.942229878 -0800
780 +++ tzu 2002-02-21 23:30:50.442260588 -0800
781 @@@@ -1,7 +1,6 @@@@
782 -The Way that can be told of is not the eternal Way;
783 -The name that can be named is not the eternal name.
785 -The Named is the mother of all things.
788 Therefore let there always be non-being,
791 @@@@ -9,3 +8,6 @@@@
803 The unified output format starts with a two-line header, which looks
807 --- @var{from-file} @var{from-file-modification-time}
808 +++ @var{to-file} @var{to-file-modification-time}
813 The time stamp looks like @samp{2002-02-21 23:30:39.942229878 -0800}
819 @option{--label=@var{label}} option; see @xref{Alternate Names}.
825 @@@@ @var{from-file-line-numbers} @var{to-file-line-numbers} @@@@
826 @var{line-from-either-file}
827 @var{line-from-either-file}@dots{}
847 @item -
875 source code for C or similar languages, use the @option{-F @var{regexp}}
876 or @option{--show-function-line=@var{regexp}} option. @command{diff}
877 considers lines that match the @command{grep}-style regular expression
897 The @option{-F} or @option{--show-function-line} option finds the nearest
906 means that you can use @option{-p} and @option{-F} together, if you wish.
914 languages, you can use the @option{-p} or @option{--show-c-function} option.
917 You can override that number with @option{-C @var{lines}} elsewhere in the
919 @option{-U @var{lines}} elsewhere in the command line.
921 The @option{-p} or @option{--show-c-function} option is equivalent to
922 @option{-F '^[[:alpha:]$_]'} if the unified format is specified, otherwise
923 @option{-c -F '^[[:alpha:]$_]'} (@pxref{Specified Headings}). @acronym{GNU}
934 @option{--label=@var{label}} option. The first time
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
940 @option{--paginate} option is used (@pxref{Pagination}).
942 Here are the first two lines of the output from @samp{diff -C 2
943 --label=original --label=modified lao tzu}:
947 --- modified
953 @cindex two-column output
964 @option{--ignore} options (@pxref{White Space}).
1014 The @option{-y} or @option{--side-by-side} option selects side by side
1018 with the @option{-W @var{columns}} or @option{--width=@var{columns}}
1024 The @option{--left-column} option prints only the left column of two
1025 common lines. The @option{--suppress-common-lines} option suppresses
1031 Here is the output of the command @samp{diff -y -W 72 lao tzu}
1066 standard. Use the @option{--normal} option to select this output
1088 ---
1105 @var{change-command}
1106 < @var{from-file-line}
1107 < @var{from-file-line}@dots{}
1108 ---
1109 > @var{to-file-line}
1110 > @var{to-file-line}@dots{}
1114 number or comma-separated range of lines in the first file, a single
1116 comma-separated range of lines in the second file. All line numbers are
1123 the first file. For example, @samp{8a12,15} means append lines 12--15
1125 delete lines 12--15 of file 2.
1130 more compact. For example, @samp{5,7c8,10} means change lines 5--7 of
1131 file 1 to read as lines 8--10 of file 2; or, if changing file 2 into
1132 file 1, change lines 8--10 of file 2 to read as lines 5--7 of file 1.
1137 For example, @samp{5,7d3} means delete lines 5--7 of file 1; or, if
1138 changing file 2 into file 1, append lines 5--7 of file 1 after line 3 of
1146 Several output modes produce command scripts for editing @var{from-file}
1147 to produce @var{to-file}.
1163 @option{-e} or @option{--ed} option to select this output format.
1170 If the file @file{d} contains the output of @samp{diff -e old new}, then
1171 the command @samp{(cat d && echo w) | ed - old} edits @file{old} to make
1173 @dots{}, @file{dN} contain the outputs of @samp{diff -e old new1},
1174 @samp{diff -e new1 new2}, @dots{}, @samp{diff -e newN-1 newN},
1176 ed - old} edits @file{old} to make it a copy of @file{newN}.
1186 Here is the output of @samp{diff -e lao tzu} (@pxref{Sample
1212 @var{change-command}
1213 @var{to-file-line}
1214 @var{to-file-line}@dots{}
1228 number or comma-separated range of lines in the first file and a single
1242 @samp{5,7c} means change lines 5--7 of file 1 to read as the text file
1247 @samp{5,7d} means delete lines 5--7 of file 1.
1264 compatibility with older versions of @command{diff}. Use the @option{-f} or
1265 @option{--forward-ed} option to select it.
1274 @option{-n} or @option{--rcs} option to select this output format. It
1285 Here is the output of @samp{diff -n lao tzu} (@pxref{Sample
1300 @node If-then-else
1301 @section Merging Files with If-then-else
1303 @cindex if-then-else output format
1304 @cindex C if-then-else output format
1315 To merge two files, use @command{diff} with the @option{-D @var{name}} or
1316 @option{--ifdef=@var{name}} option. The argument @var{name} is the C
1321 @code{waitpid (-1, &s, 0)} and then merge the old and new files with
1322 the @option{--ifdef=HAVE_WAITPID} option, then the affected part of your code
1330 if ((w = waitpid (-1, &s, 0)) < 0 && errno != EINTR)
1340 * Line Group Formats:: Formats for general if-then-else line groups.
1342 * Example If-then-else:: Sample if-then-else format output.
1343 * Detailed If-then-else:: A detailed description of if-then-else format.
1349 @cindex formats for if-then-else line groups
1352 applications that allow if-then-else input, including programming
1358 surrounded by @samp{\begin@{em@}}-@samp{\end@{em@}} lines, and new
1359 regions are surrounded by @samp{\begin@{bf@}}-@samp{\end@{bf@}} lines.
1363 --old-group-format='\begin@{em@}
1366 --new-group-format='\begin@{bf@}
1377 --old-group-format='\begin@{em@}
1380 --new-group-format='\begin@{bf@}
1383 --unchanged-group-format='%=' \
1384 --changed-group-format='\begin@{em@}
1397 --unchanged-group-format='' \
1398 --old-group-format='-------- %dn line%(n=1?:s) deleted at %df:
1400 --new-group-format='-------- %dN line%(N=1?:s) added after %de:
1402 --changed-group-format='-------- %dn line%(n=1?:s) changed at %df:
1403 %<-------- to:
1414 @item --old-group-format=@var{format}
1417 it is specified; otherwise it is a format that outputs the line group as-is.
1419 @item --new-group-format=@var{format}
1423 line group as-is.
1425 @item --changed-group-format=@var{format}
1430 @item --unchanged-group-format=@var{format}
1432 unchanged group format is a format that outputs the line group as-is.
1459 the then-part of an if-then-else format, which a colon would
1487 The number of lines in the group in the old file; equals @var{l} - @var{f} + 1.
1502 The flags are @samp{-} for left-justification, @samp{'} for separating
1526 output as part of a line group in if-then-else format.
1528 For example, the following command outputs text with a one-character
1530 is @samp{-} for deleted lines, @samp{|} for added lines, and a space for
1536 --old-line-format='-%l
1538 --new-line-format='|%l
1540 --unchanged-line-format=' %l
1549 @item --old-line-format=@var{format}
1552 @item --new-line-format=@var{format}
1555 @item --unchanged-line-format=@var{format}
1558 @item --line-format=@var{format}
1604 @samp{%L} with a tab character), or you should use the @option{-t} or
1605 @option{--expand-tabs} option.
1614 --old-line-format='< %l
1616 --new-line-format='> %l
1618 --old-group-format='%df%(f=l?:,%dl)d%dE
1620 --new-group-format='%dea%dF%(F=L?:,%dL)
1622 --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL)
1623 %<---
1625 --unchanged-group-format='' \
1629 @node Example If-then-else
1630 @subsection An Example of If-then-else Format
1632 Here is the output of @samp{diff -DTWO lao tzu} (@pxref{Sample
1647 Therefore let there always be non-being,
1661 @node Detailed If-then-else
1662 @subsection Detailed Description of If-then-else Format
1675 The option @option{--ifdef=@var{name}} is equivalent to
1679 --old-group-format='#ifndef @var{name}
1682 --new-group-format='#ifdef @var{name}
1685 --unchanged-group-format='%=' \
1686 --changed-group-format='#ifndef @var{name}
1693 For example, when using the @option{-D @var{name}} or
1694 @option{--ifdef=@var{name}} option, you should check that if the
1703 The @command{patch} @option{-D @var{name}} option behaves like
1704 the @command{diff} @option{-D @var{name}} option, except it operates on
1713 When an input file ends in a non-newline character, its last line is
1721 @acronym{RCS} format (@pxref{RCS}) outputs the incomplete line as-is,
1723 format normally represents incomplete lines as-is, but in some cases
1725 if-then-else line format preserves a line's incompleteness with
1732 For example, suppose @file{F} and @file{G} are one-byte files that
1740 ---
1746 (The exact message may differ in non-English locales.)
1747 @samp{diff -n F G} outputs the following without a trailing newline:
1756 @samp{diff -e F G} reports two errors and outputs the following:
1774 but if you use the @option{-s} or @option{--report-identical-files} option,
1777 subdirectories' files, but if you use the @option{-r} or
1778 @option{--recursive} option, it compares every corresponding pair of files
1788 directory given.) To do this, use the @option{-N} or @option{--new-file}
1793 @option{--unidirectional-new-file} option instead of @option{-N}.
1794 This option is like @option{-N} except that it only inserts the contents
1801 To ignore some files while comparing directories, use the @option{-x
1802 @var{pattern}} or @option{--exclude=@var{pattern}} option. This option
1807 expand it. For example, the option @option{-x '*.[ao]'} ignores any file
1811 using the options @option{-x 'RCS' -x '*,v'} ignores any file or
1815 patterns in a file, one pattern per line, and use the @option{-X
1816 @var{file}} or @option{--exclude-from=@var{file}} option. Trailing
1821 using the @option{-S @var{file}} or @option{--starting-file=@var{file}}
1828 case sensitive way. With the @option{--ignore-file-name-case} option,
1832 @option{--no-ignore-file-name-case} option cancels the effect of the
1833 @option{--ignore-file-name-case} option, reverting to the default
1836 If an @option{-x @var{pattern}} or @option{--exclude=@var{pattern}}
1837 option, or an @option{-X @var{file}} or
1838 @option{--exclude-from=@var{file}} option,
1839 is specified while the @option{--ignore-file-name-case} option is in
1851 * Pagination:: Page numbering and time-stamping @command{diff} output.
1864 to make tab-aligned columns line up correctly.
1868 @option{-t} or @option{--expand-tabs} option. To use this form of output with
1869 @command{patch}, you must give @command{patch} the @option{-l} or
1870 @option{--ignore-white-space} option (@pxref{Changed White Space}, for more
1873 @option{--tabsize=@var{columns}} option.
1883 type indicator character. Select this method with the @option{-T} or
1884 @option{--initial-tab} option.
1890 It can be convenient to have long output page-numbered and time-stamped.
1891 The @option{-l} or @option{--paginate} option does this by sending the
1893 header might look like for @samp{diff -lc lao tzu}:
1896 2002-02-22 14:20 diff -lc lao tzu Page 1
1912 make a few changes to the copy, and then often use @samp{diff -r} to
1914 read-only, you can greatly improve performance by creating the copy
1915 using hard or symbolic links (e.g., with @acronym{GNU} @samp{cp -lR} or
1916 @samp{cp -sR}). Before editing a file in the copy for the first time,
1926 changed always comes up with a near-minimal set of differences.
1930 differences. The @option{-d} or @option{--minimal} option does this;
1936 @option{--speed-large-files} option to make a different modification to
1945 non-minimal output. The @option{--horizon-lines=@var{lines}} option
1969 on whether they are two-way or three-way, and lines are annotated by
1997 Therefore let there always be non-being,
2005 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2044 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2050 Each hunk begins with a line marked @samp{====}. Three-way hunks have
2051 plain @samp{====} lines, and two-way hunks have @samp{1}, @samp{2}, or
2058 it from the commands. But with the @option{-T} or @option{--initial-tab}
2074 The range @var{r} is a comma-separated pair of line numbers, or just one
2093 hunk, the hunk is called a @dfn{three-way hunk}; if just two input files
2094 differ, it is a @dfn{two-way hunk}.
2098 @command{diff3} hunks by merging the two-way hunks output by the two
2124 because it found a two-way hunk containing @samp{a} in the first and
2126 @samp{b} common to all three files, then a three-way hunk containing
2161 well-defined as long as @var{mine} and @var{older} match in the
2190 into @var{mine} with the @option{-e} or @option{--ed} option. You can
2191 select only the nonoverlapping unmerged changes with @option{-3} or
2192 @option{--easy-only}, and you can select only the overlapping changes with
2193 @option{-x} or @option{--overlap-only}.
2195 The @option{-e}, @option{-3} and @option{-x} options select only
2200 one, you can use the @option{-A} or @option{--show-all} option
2205 Notice that @option{-e} outputs the union of the disjoint sets of changes
2206 output by @option{-3} and @option{-x}.
2208 Output of @samp{diff3 -e lao tzu tao}:
2212 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2219 Output of @samp{diff3 -3 lao tzu tao}:
2226 Output of @samp{diff3 -x lao tzu tao}:
2230 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2264 The @option{-A} or @option{--show-all} option acts like the @option{-e}
2268 -A lao tzu tao} puts brackets around the conflict where only @file{tzu}
2279 And it outputs the three-way conflict as follows:
2289 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2293 The @option{-E} or @option{--show-overlap} option outputs less information
2294 than the @option{-A} or @option{--show-all} option, because it outputs only
2296 file. Thus the @option{-E} option acts like the @option{-e} option,
2297 except that it brackets the first and third files from three-way
2298 overlapping changes. Similarly, @option{-X} acts like @option{-x}, except
2300 for the three-way overlapping change above, the @option{-E} and @option{-X}
2307 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2312 you can use the @option{--label=@var{label}}
2315 times, once for each input file. Thus @samp{diff3 -A --label X
2316 --label Y --label Z A
2317 B C} acts like @samp{diff3 -A A B C}, except that the output looks like
2325 With the @option{-m} or @option{--merge} option, @command{diff3} outputs the
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,
2329 @option{-A} is assumed.
2331 For example, the command @samp{diff3 -m lao tzu tao}
2343 Therefore let there always be non-being,
2357 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2365 With @option{-m}, incomplete lines (@pxref{Incomplete Lines}) are simply
2372 Without @option{-m}, if an @command{ed} script option is specified and an
2384 @command{diff3}, but with the @option{-i} option it behaves like
2388 The @option{-i} option requires one of the @command{ed} script options
2389 @option{-AeExX3}, and is incompatible with the merged output option
2390 @option{-m}.
2398 side-by-side @option{-y} format comparison (@pxref{Side by Side}). Use
2399 @option{-o @var{file}} or @option{--output=@var{file}} to specify where to
2420 -a -b -d -i -t -v
2421 -B -E -I @var{regexp}
2423 --expand-tabs
2424 --ignore-blank-lines --ignore-case
2425 --ignore-matching-lines=@var{regexp} --ignore-space-change
2426 --ignore-tab-expansion
2427 --left-column --minimal --speed-large-files
2428 --strip-trailing-cr --suppress-common-lines
2429 --tabsize=@var{columns} --text --version --width=@var{columns}
2433 options. The @option{-l} option is equivalent to the
2434 @option{--left-column} option, and similarly @option{-s} is equivalent
2435 to @option{--suppress-common-lines}. The meaning of the @command{sdiff}
2436 @option{-w} and @option{-W} options is interchanged from that of
2437 @command{diff}: with @command{sdiff}, @option{-w @var{columns}} is
2438 equivalent to @option{--width=@var{columns}}, and @option{-W} 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}
2441 or @option{--side-by-side} option (@pxref{Side by Side}).
2495 variable if it is set. The default is system-dependent.
2556 @item -c
2557 @itemx --context
2560 @item -e
2561 @itemx --ed
2564 @item -n
2565 @itemx --normal
2568 @item -u
2569 @itemx --unified
2586 @command{patch} also asks when the input file is read-only and matches
2590 The @option{-g @var{num}} or @option{--get=@var{num}} option affects access
2615 encapsulated by prepending @w{@samp{- }} to lines beginning with @samp{-}
2616 as per @uref{ftp://ftp.isi.edu/in-notes/rfc934.txt, Internet RFC 934},
2636 them properly. If this problem occurs, use the @option{-l} or
2637 @option{--ignore-white-space} option, which makes @command{patch} compare
2640 blanks in the input files. Non-blank
2650 patches, give @command{patch} the @option{-R} or @option{--reverse} option.
2657 the @option{-R} option set; if it can't, @command{patch} continues to apply
2666 it is a reversed patch and offers to un-apply the patch. This could be
2668 want to un-apply the patch, just answer @samp{n} to this offer and to
2669 the subsequent ``apply anyway'' question---or type @kbd{C-c} to kill the
2694 The @option{-F @var{lines}} or @option{--fuzz=@var{lines}} option sets the
2712 If the @option{--verbose} option is given, then
2746 use the @option{--dry-run} option, which causes @command{patch} to
2754 @option{--dry-run} option.
2764 @option{-N} or @option{--new-file} option, or if you supply an old or
2766 Epoch (1970-01-01 00:00:00 UTC), @command{diff} outputs a patch that
2771 The @option{-E} or @option{--remove-empty-files} option causes
2784 last-modified time stamp to the current time of day. If you are using
2792 The @option{-Z} or @option{--set-utc} option causes @command{patch} to
2798 The @option{-T} or @option{--set-time} option acts like @option{-Z} or
2799 @option{--set-utc}, except that it assumes that the context diff
2803 ambiguous when local clocks move backwards during daylight-saving time
2805 option is equivalent to @option{-Z} or @option{--set-utc}.
2808 the file's original last-modified time stamp does not match the time
2810 match the patch. However, if the @option{-f} or @option{--force}
2842 have enough slashes to satisfy the @option{-p@var{num}} or
2843 @option{--strip=@var{num}} option. The name @file{/dev/null} is also
2899 The @option{-d @var{directory}} or @option{--directory=@var{directory}}
2902 names given as arguments to other options (such as @option{-B} and
2903 @option{-o}). For example, while in a mail reading program, you can patch
2908 | patch -d /usr/src/emacs
2914 @option{-p@var{number}} or @option{--strip=@var{number}}
2923 @file{/gnu/src/emacs/etc/NEWS}. Using @option{-p0} gives the
2924 entire file name unmodified, @option{-p1} gives
2925 @file{gnu/src/emacs/etc/NEWS} (no leading slash), @option{-p4} gives
2926 @file{etc/NEWS}, and not specifying @option{-p} at all gives @file{NEWS}.
2929 in the current directory, or if you used the @option{-d @var{directory}}
2939 @samp{patch -R} (@pxref{Reversed Patches}). However, when conforming
2943 The @option{-b} or @option{--backup} option causes @command{patch} to
2945 original input. The @option{--backup-if-mismatch} option causes
2948 @option{--no-backup-if-mismatch} option causes @command{patch} to not
2965 the next release.} The @option{-z @var{backup-suffix}} or
2966 @option{--suffix=@var{backup-suffix}} option causes @command{patch} to
2967 use @var{backup-suffix} as the backup extension instead.
2983 The @option{-V @var{backup-style}} or
2984 @option{--version-control=@var{backup-style}} option takes as an
2988 @option{-V} option overrides. If @env{PATCH_VERSION_CONTROL} is not
2995 @option{-V} option are like the @acronym{GNU} Emacs @code{version-control}
3017 directory name, to produce backup file names. The @option{-B
3018 @var{prefix}} or @option{--prefix=@var{prefix}} option makes backup
3019 files by prepending @var{prefix} to them. The @option{-Y
3020 @var{prefix}} or @option{--basename-prefix=@var{prefix}} prepends
3022 instead; for example, @option{-Y ~} causes the backup name for
3023 @file{dir/file.c} to be @file{dir/~file.c}. If you use either of
3024 these prefix options, the suffix-based options are ignored.
3026 If you specify the output file with the @option{-o} option, that file is
3031 @option{--no-backup-if-mismatch} option, none of the options described
3044 patches in a single file. The @option{-r @var{reject-file}} or
3045 @option{--reject-file=@var{reject-file}} option uses @var{reject-file} as
3079 @option{--verbose} option. For example, when you give this option,
3085 occurs, by using the @option{-s}, @option{--quiet}, or @option{--silent}
3093 questions. The @option{-f} or @option{--force} option assumes that you know
3109 The @option{-t} or @option{--batch} option is similar to @option{-f}, in that
3115 (the same as @option{-f}).
3133 @option{--quoting-style=@var{word}} option controls how names are
3138 Output names as-is.
3142 @item shell-always
3147 Quote as with @samp{c} except omit the surrounding double-quote
3160 You can specify the default value of the @option{--quoting-style}
3170 If you specify the @option{--posix} option, or set the
3210 In traditional @command{patch}, the @option{-p} option's operand was
3211 optional, and a bare @option{-p} was equivalent to @option{-p0}. The
3212 @option{-p} option now requires an operand, and @option{-p@ 0} is now
3213 equivalent to @option{-p0}. For maximum compatibility, use options
3214 like @option{-p0} and @option{-p1}.
3224 behavior is now enabled with the @option{-b} or @option{--backup}
3229 behavior is enabled with the @option{--no-backup-if-mismatch} option,
3232 The @option{-b@ @var{suffix}} option of traditional @command{patch} is
3233 equivalent to the @samp{-b -z@ @var{suffix}} options of @acronym{GNU}
3242 @acronym{POSIX}-conforming; we hope it has fewer gotchas. The two methods
3244 @samp{Index:} line are all identical after prefix-stripping. Your
3272 @option{-c}
3273 @option{-d @var{dir}}
3274 @option{-D @var{define}}
3275 @option{-e}
3276 @option{-l}
3277 @option{-n}
3278 @option{-N}
3279 @option{-o @var{outfile}}
3280 @option{-p@var{num}}
3281 @option{-R}
3282 @option{-r @var{rejectfile}}
3293 harder-to-digest patch that covers all the subjects.
3314 To generate the patch, use the command @samp{diff -Naur @var{old}
3317 slashes. The @option{-N} option lets the patch create and remove
3318 files; @option{-a} lets the patch update non-text files; @option{-u}
3319 generates useful time stamps and enough context; and @option{-r} lets
3324 diff -Naur gcc-3.0.3 gcc-3.0.4
3329 use; the option @samp{-p1} is recommended. Test your procedure by
3357 when the patch consumer specifies the @option{-p@var{number}} option,
3363 diff -Naur v2.0.29/prog/README prog/README
3364 --- v2.0.29/prog/README 2002-03-10 23:30:39.942229878 -0800
3365 +++ prog/README 2002-03-17 20:49:32.442260588 -0800
3375 diff -Naur v2.0.29/prog/README v2.0.30/prog/README
3376 --- v2.0.29/prog/README 2002-03-10 23:30:39.942229878 -0800
3377 +++ v2.0.30/prog/README 2002-03-17 20:49:32.442260588 -0800
3411 The simplest way to generate a patch is to use @samp{diff -Naur}
3424 exclude them from the patch by giving @command{diff} the @option{-x
3431 Now you can create the patch using @samp{diff -Naur}. Make sure to
3455 cmp @var{options}@dots{} @var{from-file} @r{[}@var{to-file} @r{[}@var{from-skip} @r{[}@var{to-skip}…
3458 The file name @file{-} is always the standard input. @command{cmp}
3460 @var{from-skip} and @var{to-skip} operands specify how many bytes to
3462 @option{--ignore-initial=@var{from-skip}:@var{to-skip}} option.
3469 cmp: EOF on @var{shorter-file}
3476 @var{from-file} @var{to-file} differ: char @var{byte-number}, line @var{line-number}
3497 which is a single letter preceded by @samp{-}, and the other of which
3498 is a long name preceded by @samp{--}. Multiple single letter options
3500 line word: @option{-bl} is equivalent to @option{-b -l}.
3503 @item -b
3504 @itemx --print-bytes
3507 that have the high bit set with @samp{M-} (which stands for ``meta'').
3509 @item --help
3512 @item -i @var{skip}
3513 @itemx --ignore-initial=@var{skip}
3517 @option{@var{from-skip}:@var{to-skip}}, skip the first @var{from-skip}
3518 bytes of the first input file and the first @var{to-skip} bytes of the
3521 @item -l
3522 @itemx --verbose
3526 @item -n @var{count}
3527 @itemx --bytes=@var{count}
3530 @item -s
3531 @itemx --quiet
3532 @itemx --silent
3536 @item -v
3537 @itemx --version
3549 of 1000 instead. For example, @option{-n 4M} and @option{-n 4MiB} are
3550 equivalent to @option{-n 4194304}, whereas @option{-n 4MB} is
3551 equivalent to @option{-n 4000000}. This notation is upward compatible
3552 with the @uref{http://www.bipm.fr/enus/3_SI/si-prefixes.html, SI
3554 @uref{http://physics.nist.gov/cuu/Units/binary.html, IEC 60027-2
3569 @samp{k} and the IEC 60027-2 prefix is @samp{Ki}, but tradition and
3598 pebibyte: @math{2^50 = 1,125,899,906,842,624}.
3612 (@samp{Zi} is a GNU extension to IEC 60027-2.)
3619 (@samp{Yi} is a GNU extension to IEC 60027-2.)
3633 In the simplest case, two file names @var{from-file} and
3634 @var{to-file} are given, and @command{diff} compares the contents of
3635 @var{from-file} and @var{to-file}. A file name of @file{-} stands for
3636 text read from the standard input. As a special case, @samp{diff - -}
3640 the file in the directory whose name is that of the non-directory.
3641 The non-directory file must not be @file{-}.
3646 @option{-r} or @option{--recursive} option is given. @command{diff} never
3652 If the @option{--from-file=@var{file}} option is given, the number of
3654 Similarly, if the @option{--to-file=@var{file}} option is given, each
3657 @command{diff} options begin with @samp{-}, so normally file names
3658 may not begin with @samp{-}. However, @option{--} as an
3660 they begin with @samp{-}.
3665 @option{-a} or @option{--text} option, or the @option{-q} or
3666 @option{--brief} option.
3679 of which is a single letter preceded by @samp{-}, and the other of
3680 which is a long name preceded by @samp{--}. Multiple single letter
3682 command line word: @option{-ac} is equivalent to @option{-a -c}. Long
3687 @item -a
3688 @itemx --text
3689 Treat all files as text and compare them line-by-line, even if they
3692 @item -b
3693 @itemx --ignore-space-change
3696 @item -B
3697 @itemx --ignore-blank-lines
3701 @item --binary
3704 @item -c
3708 @item -C @var{lines}
3709 @itemx --context@r{[}=@var{lines}@r{]}
3716 @option{-@var{lines}} that has effect when combined with @option{-c}
3717 or @option{-p}. @acronym{POSIX} 1003.1-2001 (@pxref{Standards
3718 conformance}) does not allow this; use @option{-C @var{lines}}
3721 @item --changed-group-format=@var{format}
3723 both files in if-then-else format. @xref{Line Group Formats}.
3725 @item -d
3726 @itemx --minimal
3730 @item -D @var{name}
3731 @itemx --ifdef=@var{name}
3733 macro @var{name}. @xref{If-then-else}.
3735 @item -e
3736 @itemx --ed
3739 @item -E
3740 @itemx --ignore-tab-expansion
3744 @item -f
3745 @itemx --forward-ed
3749 @item -F @var{regexp}
3750 @itemx --show-function-line=@var{regexp}
3755 @item --from-file=@var{file}
3758 @item --help
3761 @item --horizon-lines=@var{lines}
3766 @item -i
3767 @itemx --ignore-case
3768 Ignore changes in case; consider upper- and lower-case letters
3771 @item -I @var{regexp}
3772 @itemx --ignore-matching-lines=@var{regexp}
3776 @item --ignore-file-name-case
3780 @item -l
3781 @itemx --paginate
3784 @item --label=@var{label}
3789 @item --left-column
3793 @item --line-format=@var{format}
3794 Use @var{format} to output all input lines in if-then-else format.
3797 @item -n
3798 @itemx --rcs
3799 Output @acronym{RCS}-format diffs; like @option{-f} except that each command
3802 @item -N
3803 @itemx --new-file
3808 @item --new-group-format=@var{format}
3810 file in if-then-else format. @xref{Line Group Formats}.
3812 @item --new-line-format=@var{format}
3814 if-then-else format. @xref{Line Formats}.
3816 @item --old-group-format=@var{format}
3818 file in if-then-else format. @xref{Line Group Formats}.
3820 @item --old-line-format=@var{format}
3822 if-then-else format. @xref{Line Formats}.
3824 @item -p
3825 @itemx --show-c-function
3828 @item -q
3829 @itemx --brief
3833 @item -r
3834 @itemx --recursive
3838 @item -s
3839 @itemx --report-identical-files
3842 @item -S @var{file}
3843 @itemx --starting-file=@var{file}
3847 @item --speed-large-files
3851 @item --strip-trailing-cr
3855 @item --suppress-common-lines
3859 @item -t
3860 @itemx --expand-tabs
3864 @item -T
3865 @itemx --initial-tab
3870 @item --tabsize=@var{columns}
3874 @item --to-file=@var{file}
3877 @item -u
3881 @item --unchanged-group-format=@var{format}
3883 in if-then-else format. @xref{Line Group Formats}.
3885 @item --unchanged-line-format=@var{format}
3886 Use @var{format} to output a line common to both files in if-then-else
3889 @item --unidirectional-new-file
3894 @item -U @var{lines}
3895 @itemx --unified@r{[}=@var{lines}@r{]}
3902 @option{-@var{lines}} that has effect when combined with @option{-u}.
3903 @acronym{POSIX} 1003.1-2001 (@pxref{Standards conformance}) does not allow
3904 this; use @option{-U @var{lines}} instead.
3906 @item -v
3907 @itemx --version
3910 @item -w
3911 @itemx --ignore-all-space
3914 @item -W @var{columns}
3915 @itemx --width=@var{columns}
3919 @item -x @var{pattern}
3920 @itemx --exclude=@var{pattern}
3924 @item -X @var{file}
3925 @itemx --exclude-from=@var{file}
3929 @item -y
3930 @itemx --side-by-side
3947 At most one of these three file names may be @file{-},
3967 @item -a
3968 @itemx --text
3969 Treat all files as text and compare them line-by-line, even if they
3972 @item -A
3973 @itemx --show-all
3978 @item --diff-program=@var{program}
3982 @item -e
3983 @itemx --ed
3987 @item -E
3988 @itemx --show-overlap
3989 Like @option{-e}, except bracket lines from overlapping changes' first
3992 With @option{-E}, an overlapping change looks like this:
4002 @item --help
4005 @item -i
4008 one of the @option{-AeExX3} options, and may not be combined with @option{-m}.
4011 @item --label=@var{label}
4012 Use the label @var{label} for the brackets output by the @option{-A},
4013 @option{-E} and @option{-X} options. This option may be given up to three
4015 the input files. Thus @samp{diff3 --label X --label Y --label Z -m A
4017 @samp{diff3 -m A B C}, except that the output looks like it came from
4021 @item -m
4022 @itemx --merge
4025 works even for binary files and incomplete lines. @option{-A} is assumed
4028 @item --strip-trailing-cr
4032 @item -T
4033 @itemx --initial-tab
4037 @item -v
4038 @itemx --version
4041 @item -x
4042 @itemx --overlap-only
4043 Like @option{-e}, except output only the overlapping changes.
4046 @item -X
4047 Like @option{-E}, except output only the overlapping changes.
4048 In other words, like @option{-x}, except bracket changes as in @option{-E}.
4051 @item -3
4052 @itemx --easy-only
4053 Like @option{-e}, except output only the nonoverlapping changes.
4074 You can also specify where to read the patch from with the @option{-i
4075 @var{patchfile}} or @option{--input=@var{patchfile}} option.
4077 @file{-}, @command{patch} reads the patch (that is, the @command{diff} output)
4089 put the output with the @option{-o @var{file}} or
4090 @option{--output=@var{file}} option; however, do not use this option
4106 Multiple single-letter options that do not take an argument can be
4110 @item -b
4111 @itemx --backup
4115 @item -B @var{prefix}
4116 @itemx --prefix=@var{prefix}
4119 @item --backup-if-mismatch
4124 @item --binary
4127 @acronym{POSIX}-conforming systems like @acronym{GNU}/Linux. On systems where
4129 @samp{diff -a --binary}. @xref{Binary}.
4131 @item -c
4132 @itemx --context
4135 @item -d @var{directory}
4136 @itemx --directory=@var{directory}
4141 @item -D @var{name}
4142 @itemx --ifdef=@var{name}
4143 Make merged if-then-else output using @var{name}. @xref{If-then-else}.
4145 @item --dry-run
4149 @item -e
4150 @itemx --ed
4153 @item -E
4154 @itemx --remove-empty-files
4158 @item -f
4159 @itemx --force
4163 @item -F @var{lines}
4164 @itemx --fuzz=@var{lines}
4167 @item -g @var{num}
4168 @itemx --get=@var{num}
4173 @item --help
4176 @item -i @var{patchfile}
4177 @itemx --input=@var{patchfile}
4181 @item -l
4182 @itemx --ignore-white-space
4186 @item -n
4187 @itemx --normal
4190 @item -N
4191 @itemx --forward
4193 See also @option{-R}. @xref{Reversed Patches}.
4195 @item --no-backup-if-mismatch
4199 @item -o @var{file}
4200 @itemx --output=@var{file}
4203 @item -p@var{number}
4204 @itemx --strip=@var{number}
4207 @item --posix
4211 @item --quoting-style=@var{word}
4216 @item -r @var{reject-file}
4217 @itemx --reject-file=@var{reject-file}
4218 Use @var{reject-file} as the reject file name. @xref{Reject Names}.
4220 @item -R
4221 @itemx --reverse
4225 @item -s
4226 @itemx --quiet
4227 @itemx --silent
4230 @item -t
4231 @itemx --batch
4234 @item -T
4235 @itemx --set-time
4240 @item -u
4241 @itemx --unified
4244 @item -v
4245 @itemx --version
4248 @item -V @var{backup-style}
4249 @itemx --version=control=@var{backup-style}
4252 @item --verbose
4255 @item -x @var{number}
4256 @itemx --debug=@var{number}
4260 @item -Y @var{prefix}
4261 @itemx --basename-prefix=@var{prefix}
4264 @item -z @var{suffix}
4265 @itemx --suffix=@var{suffix}
4269 @item -Z
4270 @itemx --set-utc
4286 sdiff -o @var{outfile} @var{options}@dots{} @var{from-file} @var{to-file}
4289 This merges @var{from-file} with @var{to-file}, with output to @var{outfile}.
4290 If @var{from-file} is a directory and @var{to-file} is not, @command{sdiff}
4291 compares the file in @var{from-file} whose file name is that of @var{to-file},
4292 and vice versa. @var{from-file} and @var{to-file} may not both be
4295 @command{sdiff} options begin with @samp{-}, so normally @var{from-file}
4296 and @var{to-file} may not begin with @samp{-}. However, @option{--} as an
4298 they begin with @samp{-}. You may not use @file{-} as an input file.
4300 @command{sdiff} without @option{-o} (or @option{--output}) produces a
4301 side-by-side difference. This usage is obsolete; use the @option{-y}
4302 or @option{--side-by-side} option of @command{diff} instead.
4318 which is a single letter preceded by @samp{-}, and the other of which
4319 is a long name preceded by @samp{--}. Multiple single letter options
4325 @item -a
4326 @itemx --text
4327 Treat all files as text and compare them line-by-line, even if they
4330 @item -b
4331 @itemx --ignore-space-change
4334 @item -B
4335 @itemx --ignore-blank-lines
4339 @item -d
4340 @itemx --minimal
4345 @item --diff-program=@var{program}
4349 @item -E
4350 @itemx --ignore-tab-expansion
4354 @item --help
4357 @item -i
4358 @itemx --ignore-case
4359 Ignore changes in case; consider upper- and lower-case to be the same.
4362 @item -I @var{regexp}
4363 @itemx --ignore-matching-lines=@var{regexp}
4367 @item -l
4368 @itemx --left-column
4372 @item -o @var{file}
4373 @itemx --output=@var{file}
4376 @item -s
4377 @itemx --suppress-common-lines
4380 @item --speed-large-files
4384 @item --strip-trailing-cr
4388 @item -t
4389 @itemx --expand-tabs
4393 @item --tabsize=@var{columns}
4397 @item -v
4398 @itemx --version
4401 @item -w @var{columns}
4402 @itemx --width=@var{columns}
4405 option is @option{-W} in @command{diff}, @option{-w} in @command{sdiff}.
4407 @item -W
4408 @itemx --ignore-all-space
4410 Note that for historical reasons, this option is @option{-w} in @command{diff},
4411 @option{-W} in @command{sdiff}.
4427 @samp{diff lao tzu -C 2} acts like @samp{diff -C 2 lao tzu}, since
4428 @samp{2} is an option-argument of @option{-C}. However, if the
4434 command @samp{diff -c -10} to have the same meaning as @samp{diff -C
4435 10}, but @acronym{POSIX} 1003.1-2001 @samp{diff} no longer allows
4436 digit-string options like @option{-10}.
4445 @acronym{POSIX} 1003.2-1992, and @samp{200112} stands for @acronym{POSIX}
4446 1003.1-2001. For example, if you are running older software that
4447 assumes an older version of @acronym{POSIX} and uses @samp{diff -c -10},
4482 * Internationalization:: Handling multibyte and varying-width characters.
4492 @subsection Handling Multibyte and Varying-Width Characters
4494 @cindex varying-width characters
4503 that use UTF-8 encoding. This causes problems with the @option{-y} or
4504 @option{--side-by-side} option of @command{diff}.
4511 @uref{http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.…
4523 with the same name @samp{D}. @samp{diff -r} does not output enough
4545 were the pointed-to files, except that a recursive @command{diff}
4565 white space, @samp{diff -r} generates a patch that @command{patch} cannot
4575 Applying @command{patch} to a multiple-file diff can result in files
4587 @var{from-file} and one in @var{to-file}, which should be considered to
4599 sed 's/foo/bar/g' file1 | diff - file2
4609 with @samp{cp -pR}), it would greatly improve performance if an option
4621 @uref{http://mail.gnu.org/mailman/listinfo/bug-gnu-utils,GNU utilities
4622 bug report mailing list} @email{bug-gnu-utils@@gnu.org}. Please send
4624 @email{bug-patch@@gnu.org}. Send as precise a description of the
4625 problem as you can, including the output of the @option{--version}