📄 cksum.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>cksum</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_073"> </a>NAME</h4><blockquote>cksum - write file checksums and sizes</blockquote><h4><a name = "tag_001_014_074"> </a>SYNOPSIS</h4><blockquote><pre><code>cksum <b>[</b><i>file</i> ...<b>]</b></code></pre></blockquote><h4><a name = "tag_001_014_075"> </a>DESCRIPTION</h4><blockquote>The<i>cksum</i>utility calculates andwrites to standard output acyclic redundancy check (CRC) for each input file,and also writes to standard output the number ofoctets in each file.The CRC used is based on the polynomial used for CRC errorchecking in the referenced Ethernet standard.<p>The encoding for the CRC checksum is defined by the generating polynomial:<p><dl compact><dt> <dd><i>G</i>(<i>x</i>) =<i>x</i><sup><small>32</small></sup> +<i>x</i><sup><small>26</small></sup> +<i>x</i><sup><small>23</small></sup> +<i>x</i><sup><small>22</small></sup> +<i>x</i><sup><small>16</small></sup> +<i>x</i><sup><small>12</small></sup> +<i>x</i><sup><small>11</small></sup> +<i>x</i><sup><small>10</small></sup> +<i>x</i><sup><small>8</small></sup> +<i>x</i><sup><small>7</small></sup> +<i>x</i><sup><small>5</small></sup> +<i>x</i><sup><small>4</small></sup> +<i>x</i><sup><small>2</small></sup> +<i>x</i> +1</dl></p><p>Mathematically, the CRC value corresponding to a given file is definedby the following procedure:<ol><p><li>The<i>n</i>bits to be evaluated are considered to be the coefficientsof a mod 2 polynomial<i>M ( x</i>of degree<i>n</i>-1.These<i>n</i>bits are the bits from the file,with the most significant bit being the most significant bitof the first octet of the file and thelast bit being the least significant bit of the last octet,padded with zero bits(if necessary) to achieve an integral number of octets,followed by one or more octets representing the length of thefile as a binary value, least significant octet first.The smallest number of octets capable of representingthis integer is used.<p><li><i>M ( x</i>is multiplied by<i>x</i><sup><small>32</small></sup>(that is, shifted left 32 bits) anddivided by<i>G ( x</i>using mod 2 division, producing a remainder<i>R ( x</i>of degree <= 31.<p><li>The coefficients of<i>R ( x</i>are considered to be a 32-bit sequence.<p><li>The bit sequence is complemented and the result is the CRC.<p></ol></blockquote><h4><a name = "tag_001_014_076"> </a>OPTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_077"> </a>OPERANDS</h4><blockquote>The following operand is supported:<dl compact><dt><i>file</i><dd>A pathname of a file to be checked.If no<i>file</i>operands are specified,the standard input is used.</dl></blockquote><h4><a name = "tag_001_014_078"> </a>STDIN</h4><blockquote>The standard input is used only if no<i>file</i>operands are specified.See the INPUT FILES section.</blockquote><h4><a name = "tag_001_014_079"> </a>INPUT FILES</h4><blockquote>The input files can be any file type.</blockquote><h4><a name = "tag_001_014_080"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>cksum</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 error.<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_081"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_082"> </a>STDOUT</h4><blockquote>For each file processed successfully, the<i>cksum</i>utility will write in the following format:<p><code><tt>"%u %d %s\n"</tt>, <<i>checksum</i>>,<<i># of octets</i>>,<<i>pathname</i>></code><p>If no<i>file</i>operand was specified, the pathname and its leading space will be omitted.</blockquote><h4><a name = "tag_001_014_083"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_084"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_085"> </a>EXTENDED DESCRIPTION</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_086"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>All files were processed successfully.<dt>>0<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_087"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_088"> </a>APPLICATION USAGE</h4><blockquote>The<i>cksum</i>utility is typically used toquickly compare a suspect file against atrusted version of the same, such as toensure that files transmitted over noisy media arrive intact.However, this comparisoncannot be considered cryptographically secure.The chances of a damaged file producing the same CRCas the original are small; deliberatedeception is difficult, but probably not impossible.<p>Although input files to<i>cksum</i>can be any type, the results need 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,checksums of character special files need not process all of the data inthose files.<p>The algorithm is expressed in terms of a bitstream divided into octets.If a file is transmitted between two systems and undergoesany data transformation (such as moving 8-bit characters into 9-bitbytes or changing "Little Endian" byte ordering to "Big Endian"),identical CRC values cannot be expected.Implementations performing such transformations may extend<i>cksum</i>to handle such situations.</blockquote><h4><a name = "tag_001_014_089"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_090"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_091"> </a>SEE ALSO</h4><blockquote>None.</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 + -