/usr/share/doc/diffutils-doc/Comparing-Three-Files.html is in diffutils-doc 1:3.5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This manual is for GNU Diffutils
(version 3.5, 4 August 2016),
and documents the GNU diff, diff3,
sdiff, and cmp commands for showing the
differences between files and the GNU patch command for
using their output to update files.
Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2016 Free
Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled
"GNU Free Documentation License." -->
<!-- Created by GNU Texinfo 6.3, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Comparing and Merging Files: Comparing Three Files</title>
<meta name="description" content="Comparing and Merging Files: Comparing Three Files">
<meta name="keywords" content="Comparing and Merging Files: Comparing Three Files">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="index.html#Top" rel="up" title="Top">
<link href="diff3-Merging.html#diff3-Merging" rel="next" title="diff3 Merging">
<link href="diff-Performance.html#diff-Performance" rel="prev" title="diff Performance">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<a name="Comparing-Three-Files"></a>
<div class="header">
<p>
Next: <a href="diff3-Merging.html#diff3-Merging" accesskey="n" rel="next">diff3 Merging</a>, Previous: <a href="diff-Performance.html#diff-Performance" accesskey="p" rel="prev">diff Performance</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Comparing-Three-Files-1"></a>
<h2 class="chapter">7 Comparing Three Files</h2>
<a name="index-comparing-three-files"></a>
<a name="index-format-of-diff3-output"></a>
<p>Use the program <code>diff3</code> to compare three files and show any
differences among them. (<code>diff3</code> can also merge files; see
<a href="diff3-Merging.html#diff3-Merging">diff3 Merging</a>).
</p>
<p>The “normal” <code>diff3</code> output format shows each hunk of
differences without surrounding context. Hunks are labeled depending
on whether they are two-way or three-way, and lines are annotated by
their location in the input files.
</p>
<p>See <a href="Invoking-diff3.html#Invoking-diff3">Invoking diff3</a>, for more information on how to run <code>diff3</code>.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Sample-diff3-Input" accesskey="1">Sample diff3 Input</a>:</td><td> </td><td align="left" valign="top">Sample <code>diff3</code> input for examples.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Example-diff3-Normal" accesskey="2">Example diff3 Normal</a>:</td><td> </td><td align="left" valign="top">Sample output in the normal format.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Detailed-diff3-Normal" accesskey="3">Detailed diff3 Normal</a>:</td><td> </td><td align="left" valign="top">A detailed description of normal output format.
</td></tr>
<tr><td align="left" valign="top">• <a href="#diff3-Hunks" accesskey="4">diff3 Hunks</a>:</td><td> </td><td align="left" valign="top">The format of normal output format.
</td></tr>
</table>
<hr>
<a name="Sample-diff3-Input"></a>
<div class="header">
<p>
Next: <a href="#Example-diff3-Normal" accesskey="n" rel="next">Example diff3 Normal</a>, Up: <a href="#Comparing-Three-Files" accesskey="u" rel="up">Comparing Three Files</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="A-Third-Sample-Input-File"></a>
<h3 class="section">7.1 A Third Sample Input File</h3>
<a name="index-diff3-sample-input"></a>
<a name="index-sample-input-for-diff3"></a>
<p>Here is a third sample file that will be used in examples to illustrate
the output of <code>diff3</code> and how various options can change it. The
first two files are the same that we used for <code>diff</code> (see <a href="Output-Formats.html#Sample-diff-Input">Sample diff Input</a>). This is the third sample file, called <samp>tao</samp>:
</p>
<div class="example">
<pre class="example">The Way that can be told of is not the eternal Way;
The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
The named is the mother of all things.
Therefore let there always be non-being,
so we may see their subtlety,
And let there always be being,
so we may see their result.
The two are the same,
But after they are produced,
they have different names.
-- The Way of Lao-Tzu, tr. Wing-tsit Chan
</pre></div>
<hr>
<a name="Example-diff3-Normal"></a>
<div class="header">
<p>
Next: <a href="#Detailed-diff3-Normal" accesskey="n" rel="next">Detailed diff3 Normal</a>, Previous: <a href="#Sample-diff3-Input" accesskey="p" rel="prev">Sample diff3 Input</a>, Up: <a href="#Comparing-Three-Files" accesskey="u" rel="up">Comparing Three Files</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="An-Example-of-diff3-Normal-Format"></a>
<h3 class="section">7.2 An Example of <code>diff3</code> Normal Format</h3>
<p>Here is the output of the command ‘<samp>diff3 lao tzu tao</samp>’
(see <a href="#Sample-diff3-Input">Sample diff3 Input</a>, for the complete contents of the files).
Notice that it shows only the lines that are different among the three
files.
</p>
<div class="example">
<pre class="example">====2
1:1,2c
3:1,2c
The Way that can be told of is not the eternal Way;
The name that can be named is not the eternal name.
2:0a
====1
1:4c
The Named is the mother of all things.
2:2,3c
3:4,5c
The named is the mother of all things.
====3
1:8c
2:7c
so we may see their outcome.
3:9c
so we may see their result.
====
1:11a
2:11,13c
They both may be called deep and profound.
Deeper and more profound,
The door of all subtleties!
3:13,14c
-- The Way of Lao-Tzu, tr. Wing-tsit Chan
</pre></div>
<hr>
<a name="Detailed-diff3-Normal"></a>
<div class="header">
<p>
Next: <a href="#diff3-Hunks" accesskey="n" rel="next">diff3 Hunks</a>, Previous: <a href="#Example-diff3-Normal" accesskey="p" rel="prev">Example diff3 Normal</a>, Up: <a href="#Comparing-Three-Files" accesskey="u" rel="up">Comparing Three Files</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Detailed-Description-of-diff3-Normal-Format"></a>
<h3 class="section">7.3 Detailed Description of <code>diff3</code> Normal Format</h3>
<p>Each hunk begins with a line marked ‘<samp>====</samp>’. Three-way hunks have
plain ‘<samp>====</samp>’ lines, and two-way hunks have ‘<samp>1</samp>’, ‘<samp>2</samp>’, or
‘<samp>3</samp>’ appended to specify which of the three input files differ in
that hunk. The hunks contain copies of two or three sets of input
lines each preceded by one or two commands identifying where the lines
came from.
</p>
<p>Normally, two spaces precede each copy of an input line to distinguish
it from the commands. But with the <samp>--initial-tab</samp> (<samp>-T</samp>)
option, <code>diff3</code> uses a tab instead of two spaces; this lines up
tabs correctly. See <a href="Adjusting-Output.html#Tabs">Tabs</a>, for more information.
</p>
<p>Commands take the following forms:
</p>
<dl compact="compact">
<dt>‘<samp><var>file</var>:<var>l</var>a</samp>’</dt>
<dd><p>This hunk appears after line <var>l</var> of file <var>file</var>, and
contains no lines in that file. To edit this file to yield the other
files, one must append hunk lines taken from the other files. For
example, ‘<samp>1:11a</samp>’ means that the hunk follows line 11 in the first
file and contains no lines from that file.
</p>
</dd>
<dt>‘<samp><var>file</var>:<var>r</var>c</samp>’</dt>
<dd><p>This hunk contains the lines in the range <var>r</var> of file <var>file</var>.
The range <var>r</var> is a comma-separated pair of line numbers, or just one
number if there is only one line. To edit this file to yield the
other files, one must change the specified lines to be the lines taken
from the other files. For example, ‘<samp>2:11,13c</samp>’ means that the hunk
contains lines 11 through 13 from the second file.
</p></dd>
</dl>
<p>If the last line in a set of input lines is incomplete
(see <a href="Incomplete-Lines.html#Incomplete-Lines">Incomplete Lines</a>), it is distinguished on output from a full
line by a following line that starts with ‘<samp>\</samp>’.
</p>
<hr>
<a name="diff3-Hunks"></a>
<div class="header">
<p>
Previous: <a href="#Detailed-diff3-Normal" accesskey="p" rel="prev">Detailed diff3 Normal</a>, Up: <a href="#Comparing-Three-Files" accesskey="u" rel="up">Comparing Three Files</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="diff3-Hunks-1"></a>
<h3 class="section">7.4 <code>diff3</code> Hunks</h3>
<a name="index-hunks-for-diff3"></a>
<a name="index-diff3-hunks"></a>
<p>Groups of lines that differ in two or three of the input files are
called <em>diff3 hunks</em>, by analogy with <code>diff</code> hunks
(see <a href="Comparison.html#Hunks">Hunks</a>). If all three input files differ in a <code>diff3</code>
hunk, the hunk is called a <em>three-way hunk</em>; if just two input files
differ, it is a <em>two-way hunk</em>.
</p>
<p>As with <code>diff</code>, several solutions are possible. When comparing the
files ‘<samp>A</samp>’, ‘<samp>B</samp>’, and ‘<samp>C</samp>’, <code>diff3</code> normally finds
<code>diff3</code> hunks by merging the two-way hunks output by the two
commands ‘<samp>diff A B</samp>’ and ‘<samp>diff A C</samp>’. This does not necessarily
minimize the size of the output, but exceptions should be rare.
</p>
<p>For example, suppose <samp>F</samp> contains the three lines ‘<samp>a</samp>’,
‘<samp>b</samp>’, ‘<samp>f</samp>’, <samp>G</samp> contains the lines ‘<samp>g</samp>’, ‘<samp>b</samp>’,
‘<samp>g</samp>’, and <samp>H</samp> contains the lines ‘<samp>a</samp>’, ‘<samp>b</samp>’,
‘<samp>h</samp>’. ‘<samp>diff3 F G H</samp>’ might output the following:
</p>
<div class="example">
<pre class="example">====2
1:1c
3:1c
a
2:1c
g
====
1:3c
f
2:3c
g
3:3c
h
</pre></div>
<p>because it found a two-way hunk containing ‘<samp>a</samp>’ in the first and
third files and ‘<samp>g</samp>’ in the second file, then the single line
‘<samp>b</samp>’ common to all three files, then a three-way hunk containing
the last line of each file.
</p>
<hr>
<div class="header">
<p>
Previous: <a href="#Detailed-diff3-Normal" accesskey="p" rel="prev">Detailed diff3 Normal</a>, Up: <a href="#Comparing-Three-Files" accesskey="u" rel="up">Comparing Three Files</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|