📄 cmp.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>cmp</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_001_014_092"> </a>NAME</h4><blockquote>cmp - compare two files</blockquote><h4><a name = "tag_001_014_093"> </a>SYNOPSIS</h4><blockquote><pre><code>cmp <b>[</b> -l | -s <b>] </b><i>file1 file2</i></code></pre></blockquote><h4><a name = "tag_001_014_094"> </a>DESCRIPTION</h4><blockquote>The<i>cmp</i>utility compares two files.The<i>cmp</i>utility will write no outputif the files are the same.Under default options,if they differ, it will write to standard outputthe byte and line number atwhich the first difference occurred.Bytes and lines will be numbered beginning with 1.</blockquote><h4><a name = "tag_001_014_095"> </a>OPTIONS</h4><blockquote>The<i>cmp</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> .<p>The following options are supported:<dl compact><dt><b>-l</b><dd>(Lower-case ell.)Write the byte number (decimal) and thediffering bytes (octal) for each difference.<dt><b>-s</b><dd>Write nothing for differing files;return exit status only.</dl></blockquote><h4><a name = "tag_001_014_096"> </a>OPERANDS</h4><blockquote>The following operands are supported:<dl compact><dt><i>file1</i><dd>A pathname of the first file to be compared.If<i>file1</i>is "-", the standard input will be used.<dt><i>file2</i><dd>A pathname of the second file to be compared.If<i>file2</i>is "-", the standard input will be used.</dl><p>If both<i>file1</i>and<i>file2</i>refer tostandard input or refer to the same FIFO special, block special orcharacter special file, the results are undefined.</blockquote><h4><a name = "tag_001_014_097"> </a>STDIN</h4><blockquote>The standard input will be used only ifthe<i>file1</i>or<i>file2</i>operand refers to standard input.See the INPUT FILES section.</blockquote><h4><a name = "tag_001_014_098"> </a>INPUT FILES</h4><blockquote>The input files can be any file type.</blockquote><h4><a name = "tag_001_014_099"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>cmp</i>:<dl compact><dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text data ascharacters (for example, single- as opposed to multi-byte charactersin arguments).<dt><i>LC_MESSAGES</i><dd>Determine the locale that should be used to affectthe format and contents of diagnosticmessages written to standard errorand informative messages written to standard output.<dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i></dl></blockquote><h4><a name = "tag_001_014_100"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_101"> </a>STDOUT</h4><blockquote>In the POSIX locale,results of the comparison will be written to standard output.When no options are used, the format will be:<p><code><pre><tt>"%s %s differ: char %d, line %d\n"</tt>, <i>file1</i>,<i>file2</i>,<<i>byte number</i>>,<<i>line</i>>number</pre></code><p>When the<b>-l</b>option is used, the format is:<p><code><pre><tt>"%d %o %o\n"</tt>, <<i>byte number</i>>,<<i>differing byte</i>>,<<i>differing byte</i>></pre></code>for each byte that differs.The first<<i>differing byte</i>>number is from<i>file1</i>while the second is from<i>file2</i>.In both cases,<<i>byte number</i>>is relative to the beginning of the file, beginning with 1.<p>No output will be written to standard output when the<b>-s</b>option is used.</blockquote><h4><a name = "tag_001_014_102"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.If<i>file1</i>and<i>file2</i>are identical for the entire length of the shorter file,in the POSIX localethe following diagnostic message will be written, unless the<b>-s</b>option is specified:<pre><code>"cmp: EOF on %s%s\n", <<i>name of shorter file</i>>, <<i>additional info</i>></code></pre><p>The<<i>additional info</i>>field is either null or a string that starts with ablank characterand contains nonewlinecharacters.Some systems report on the number of lines in this case.</blockquote><h4><a name = "tag_001_014_103"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_104"> </a>EXTENDED DESCRIPTION</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_105"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>The files are identical.<dt>1<dd>The files are different;this includes the case where one file is identical to the first part ofthe other.<dt>>1<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_106"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_107"> </a>APPLICATION USAGE</h4><blockquote>Although input files to<i>cmp</i>can be any type, the results might not bewhat would be expected on character special device files or on filetypes not described by the <b>XSH</b> specification.Since this specification does not specify the block size used when doing input,comparisons of character special files need not compare all ofthe data in those files.</blockquote><h4><a name = "tag_001_014_108"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_109"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_110"> </a>SEE ALSO</h4><blockquote><i><a href="comm.html">comm</a></i>,<i><a href="diff.html">diff</a></i>.</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 + -