📄 diff.html
字号:
into<i>file2</i>.The line numbers before the action letters pertain to<i>file1</i>;those after pertain to<i>file2</i>.Thus, by exchangingafordandreading the line in reverse order, one can also determine how to convert<i>file2</i>into<i>file1</i>.As in<i><a href="ed.html">ed</a></i>,identical pairs (where <i>num1</i><b> = </b><i>num2</i>)are abbreviated as a single number.<p>Following each of these lines,<i>diff</i>will write to standard outputall lines affected in the first file using the format:<p><code><tt>"<<img src="../images/delta.gif" border=0>%s"</tt>, <<i>line</i>></code><p>and all lines affected in the second file using the format:<p><code><tt>"><img src="../images/delta.gif" border=0>%s"</tt>, <<i>line</i>></code><p>If there are lines affected in both<i>file1</i>and<i>file2</i>(as with the<b>c</b>subcommand), the changes are separated with aline consisting of three hyphens:<pre><code>"---\n"</code></pre><h5><a name = "tag_001_014_424_003"> </a>Diff -e Output Format</h5>With the<b>-e</b>option,a script will be produced that will,when provided as input to<i><a href="ed.html">ed</a></i>,along with an appended<b>w</b>(write) command, convert<i>file1</i>into<i>file2</i>.Only the<b>a</b>(append),<b>c</b>(change),<b>d</b>(delete),<b>i</b>(insert), and<b>s</b>(substitute) commands of<i><a href="ed.html">ed</a></i>will be used in this script.Text lines, except those consisting of the single character period(.),will be output as they appear in the file.<h5><a name = "tag_001_014_424_004"> </a>Diff -f Output Format</h5>With the<b>-f</b>option,an alternative format of script will be produced.It will be similar to that produced by<b>-e</b>,with the following differences:<ol><p><li>It will be expressed in reverse sequence;the output of<b>-e</b>will order changes from the end of the file to the beginning;the<b>-f</b>from beginning to end.<p><li>The command form<<i>lines</i>><<i>command-letter</i>>used by<b>-e</b>will be reversed.For example,10cwith<b>-e</b>would bec10with<b>-f</b>.<p><li>The form used for ranges of line numbers will bespace-character-separated,rather than comma-separated.<p></ol><h5><a name = "tag_001_014_424_005"> </a>Diff -c or -C Output Format</h5>With the<b>-c</b>or<b>-C</b>option, the output format will consist of affected lines along withsurrounding lines of context.The affected lines will show whichones need to be deleted or changed in<i>file1</i>,and thoseadded from<i>file2</i>.With the<b>-c</b>option,three lines of context,if available, will be written before andafter the affected lines.With the<b>-C</b>option, the usercan specify how many lines of context will be written.The exact format follows.<p>The name and last modification timeof each file will be output in the following format:<p><code><pre><tt>"*** %s %s\n"</tt>, <i>file1</i>,<<i>file1 time stamp</i>><tt>"--- %s %s\n"</tt>, <i>file2</i>,<<i>file2 time stamp</i>></code></pre>and a string of 15 asterisks:<pre><code>"***************\n"</code></pre><p>Each<<i>file</i>>field will be the pathname of the corresponding file being compared.The pathname written for standard input is unspecified.<p>In the POSIX locale, each<<i>timestamp</i>>field will be equivalent to theoutput from the following command:<pre><code>date "+%a %b %e %T %Y"</code></pre>without the trailingnewline character,executed at the time of last modificationof the corresponding file(or the current time, if the file is standard input).<p>Then, the following output formats will be applied for every set of changes.<p>First, the range of lines in<i>file1</i>will be written in the following format:<p><code><tt>"*** %d,%d ****\n"</tt>, <<i>beginning line number</i>>,<<i>ending line number</i>></code><p>Next, the affected lines along with lines of context (unaffected lines)will be written.Unaffected lines will be written in the following format:<p><code><tt>"<img src="../images/delta.gif" border=0>%s"</tt>, <<i>unaffected_line</i>></code><p>Deleted lines will be written as:<p><code><tt>"-<img src="../images/delta.gif" border=0>2%s"</tt>, <<i>deleted_line</i>></code><p>Changed lines will be written as:<p><code><tt>"!<img src="../images/delta.gif" border=0>%s"</tt>, <<i>changed_line</i>></code><p>Next, the range of lines in<i>file2</i>will be written in the following format:<p><code><tt>"--- %d,%d ----\n"</tt>, <<i>beginning line number</i>>,<<i>ending line number</i>></code><p>Then, lines of context and changed lines will be written as describedin the previous formats.Lines added from<i>file2</i>will be written in the following format:<p><code><tt>"+<img src="../images/delta.gif" border=0>%s"</tt>, <<i>added_line</i>></code></blockquote><h4><a name = "tag_001_014_425"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_426"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_427"> </a>EXTENDED DESCRIPTION</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_428"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>No differences were found.<dt>1<dd>Differences were found.<dt>>1<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_429"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_430"> </a>APPLICATION USAGE</h4><blockquote>If lines at the end of a file are changed and other lines are added,<i>diff</i>output may show this as a delete and add, as a change, or as a change andadd;<i>diff</i>is not expected to know which happened and users should notcare about the difference in output as long as it clearly shows thedifferences between the files.</blockquote><h4><a name = "tag_001_014_431"> </a>EXAMPLES</h4><blockquote>If<b>dir1</b>is a directory containing a directory named<b>x</b>,<b>dir2</b>is a directory containing a directory named<b>x</b>,<b>dir1/x</b>and<b>dir2/x</b>both contain files named<b>date.out</b>,and<b>dir2/x</b>contains a file named<b>y</b>,the command:<pre><code>diff -r dir1 dir2</code></pre>could produce output similar to:<pre><code>Common subdirectories: dir1/x and dir2/xOnly in dir2/x: ydiff -r dir1/x/date.out dir2/x/date.out1c1< Mon Jul 2 13:12:16 PDT 1990---> Tue Jun 19 21:41:39 PDT 1990</code></pre></blockquote><h4><a name = "tag_001_014_432"> </a>FUTURE DIRECTIONS</h4><blockquote>The IEEE PASC 1003.2 Interpretations Committee has forwarded concerns about parts of this interface definition to the IEEE PASC Shell and Utilities Working Groupwhich is identifying the corrections.A future revision of this specification will align withIEEE Std. 1003.2b when finalised.</blockquote><h4><a name = "tag_001_014_433"> </a>SEE ALSO</h4><blockquote><i><a href="cmp.html">cmp</a></i>,<i><a href="comm.html">comm</a></i>,<i><a href="dircmp.html">dircmp</a></i>,<i><a href="ed.html">ed</a></i>.<br></blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -