isposix

Un outil pour savoir si une commande est posix - retour accueil

git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |

wc.html (13428B)


      1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved -->
      2 <!DOCTYPE HTML>
      3 <html lang="en">
      4 <head>
      5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0">
      6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 -->
      8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved -->
      9 <title>wc</title>
     10 </head>
     11 <body bgcolor="white">
     12 <div class="NAVHEADER">
     13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
     14 <tr class="nav">
     15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/wait.html" accesskey="P">&lt;&lt;&lt;
     16 Previous</a></td>
     17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
     18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/what.html" accesskey="N">Next &gt;&gt;&gt;</a></td>
     19 </tr>
     20 </table>
     21 <hr align="left" width="100%"></div>
     22 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3">
     23 <center><font size="2">The Open Group Base Specifications Issue 8<br>
     24 IEEE Std 1003.1-2024<br>
     25 Copyright © 2001-2024 The IEEE and The Open Group</font></center>
     26 <hr size="2" noshade>
     27 <a name="top" id="top"></a> <a name="wc" id="wc"></a> <a name="tag_20_148" id="tag_20_148"></a><!-- wc -->
     28 <h4 class="mansect"><a name="tag_20_148_01" id="tag_20_148_01"></a>NAME</h4>
     29 <blockquote>wc — word, line, and byte or character count</blockquote>
     30 <h4 class="mansect"><a name="tag_20_148_02" id="tag_20_148_02"></a>SYNOPSIS</h4>
     31 <blockquote class="synopsis">
     32 <p><code><tt>wc</tt> <b>[</b><tt>-c|-m</tt><b>] [</b><tt>-lw</tt><b>] [</b><i>file</i><tt>...</tt><b>]</b></code></p>
     33 </blockquote>
     34 <h4 class="mansect"><a name="tag_20_148_03" id="tag_20_148_03"></a>DESCRIPTION</h4>
     35 <blockquote>
     36 <p>The <i>wc</i> utility shall read one or more input files and, by default, write the number of &lt;newline&gt; characters, words,
     37 and bytes contained in each input file to the standard output.</p>
     38 <p>The utility also shall write a total count for all named files, if more than one input file is specified.</p>
     39 <p>The <i>wc</i> utility shall consider a <i>word</i> to be a non-zero-length string of characters delimited by white space.</p>
     40 </blockquote>
     41 <h4 class="mansect"><a name="tag_20_148_04" id="tag_20_148_04"></a>OPTIONS</h4>
     42 <blockquote>
     43 <p>The <i>wc</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     44 Guidelines</i></a> .</p>
     45 <p>The following options shall be supported:</p>
     46 <dl compact>
     47 <dd></dd>
     48 <dt><b>-c</b></dt>
     49 <dd>Write to the standard output the number of bytes in each input file.</dd>
     50 <dt><b>-l</b></dt>
     51 <dd>Write to the standard output the number of &lt;newline&gt; characters in each input file.</dd>
     52 <dt><b>-m</b></dt>
     53 <dd>Write to the standard output the number of characters in each input file.</dd>
     54 <dt><b>-w</b></dt>
     55 <dd>Write to the standard output the number of words in each input file.</dd>
     56 </dl>
     57 <p>When any option is specified, <i>wc</i> shall report only the information requested by the specified options.</p>
     58 </blockquote>
     59 <h4 class="mansect"><a name="tag_20_148_05" id="tag_20_148_05"></a>OPERANDS</h4>
     60 <blockquote>
     61 <p>The following operand shall be supported:</p>
     62 <dl compact>
     63 <dd></dd>
     64 <dt><i>file</i></dt>
     65 <dd>A pathname of an input file. If no <i>file</i> operands are specified, the standard input shall be used.</dd>
     66 </dl>
     67 </blockquote>
     68 <h4 class="mansect"><a name="tag_20_148_06" id="tag_20_148_06"></a>STDIN</h4>
     69 <blockquote>
     70 <p>The standard input shall be used if no <i>file</i> operands are specified, and shall be used if a <i>file</i> operand is
     71 <tt>'-'</tt> and the implementation treats the <tt>'-'</tt> as meaning standard input. Otherwise, the standard input shall not be
     72 used. See the INPUT FILES section.</p>
     73 </blockquote>
     74 <h4 class="mansect"><a name="tag_20_148_07" id="tag_20_148_07"></a>INPUT FILES</h4>
     75 <blockquote>
     76 <p>The input files may be of any type.</p>
     77 </blockquote>
     78 <h4 class="mansect"><a name="tag_20_148_08" id="tag_20_148_08"></a>ENVIRONMENT VARIABLES</h4>
     79 <blockquote>
     80 <p>The following environment variables shall affect the execution of <i>wc</i>:</p>
     81 <dl compact>
     82 <dd></dd>
     83 <dt><i>LANG</i></dt>
     84 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
     85 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
     86 variables used to determine the values of locale categories.)</dd>
     87 <dt><i>LC_ALL</i></dt>
     88 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
     89 <dt><i>LC_CTYPE</i></dt>
     90 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
     91 opposed to multi-byte characters in arguments and input files) and which characters are defined as white-space characters.</dd>
     92 <dt><i>LC_MESSAGES</i></dt>
     93 <dd><br>
     94 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and
     95 informative messages written to standard output.</dd>
     96 <dt><i>NLSPATH</i></dt>
     97 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
     98 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
     99 "0"></dd>
    100 </dl>
    101 </blockquote>
    102 <h4 class="mansect"><a name="tag_20_148_09" id="tag_20_148_09"></a>ASYNCHRONOUS EVENTS</h4>
    103 <blockquote>
    104 <p>Default.</p>
    105 </blockquote>
    106 <h4 class="mansect"><a name="tag_20_148_10" id="tag_20_148_10"></a>STDOUT</h4>
    107 <blockquote>
    108 <p>By default, the standard output shall contain an entry for each input file of the form:</p>
    109 <pre>
    110 <tt>"%d %d %d %s\n", &lt;</tt><i>newlines</i><tt>&gt;, &lt;</tt><i>words</i><tt>&gt;, &lt;</tt><i>bytes</i><tt>&gt;, &lt;</tt><i>file</i><tt>&gt;
    111 </tt></pre>
    112 <p>If the <b>-m</b> option is specified, the number of characters shall replace the &lt;<i>bytes</i>&gt; field in this format.</p>
    113 <p>If any options are specified and the <b>-l</b> option is not specified, the number of &lt;newline&gt; characters shall not be
    114 written.</p>
    115 <p>If any options are specified and the <b>-w</b> option is not specified, the number of words shall not be written.</p>
    116 <p>If any options are specified and neither <b>-c</b> nor <b>-m</b> is specified, the number of bytes or characters shall not be
    117 written.</p>
    118 <p>If no input <i>file</i> operands are specified, no name shall be written and no &lt;blank&gt; characters preceding the pathname
    119 shall be written.</p>
    120 <p>If more than one input <i>file</i> operand is specified, an additional line shall be written, of the same format as the other
    121 lines, except that the word <b>total</b> (in the POSIX locale) shall be written instead of a pathname and the total of each column
    122 shall be written as appropriate. Such an additional line, if any, is written at the end of the output.</p>
    123 </blockquote>
    124 <h4 class="mansect"><a name="tag_20_148_11" id="tag_20_148_11"></a>STDERR</h4>
    125 <blockquote>
    126 <p>The standard error shall be used only for diagnostic messages.</p>
    127 </blockquote>
    128 <h4 class="mansect"><a name="tag_20_148_12" id="tag_20_148_12"></a>OUTPUT FILES</h4>
    129 <blockquote>
    130 <p>None.</p>
    131 </blockquote>
    132 <h4 class="mansect"><a name="tag_20_148_13" id="tag_20_148_13"></a>EXTENDED DESCRIPTION</h4>
    133 <blockquote>
    134 <p>None.</p>
    135 </blockquote>
    136 <h4 class="mansect"><a name="tag_20_148_14" id="tag_20_148_14"></a>EXIT STATUS</h4>
    137 <blockquote>
    138 <p>The following exit values shall be returned:</p>
    139 <dl compact>
    140 <dd></dd>
    141 <dt>&nbsp;0</dt>
    142 <dd>Successful completion.</dd>
    143 <dt>&gt;0</dt>
    144 <dd>An error occurred.</dd>
    145 </dl>
    146 </blockquote>
    147 <h4 class="mansect"><a name="tag_20_148_15" id="tag_20_148_15"></a>CONSEQUENCES OF ERRORS</h4>
    148 <blockquote>
    149 <p>Default.</p>
    150 </blockquote>
    151 <hr>
    152 <div class="box"><em>The following sections are informative.</em></div>
    153 <h4 class="mansect"><a name="tag_20_148_16" id="tag_20_148_16"></a>APPLICATION USAGE</h4>
    154 <blockquote>
    155 <p>The <b>-m</b> option is not a switch, but an option at the same level as <b>-c</b>. Thus, to produce the full default output
    156 with character counts instead of bytes, the command required is:</p>
    157 <pre>
    158 <tt>wc -mlw
    159 </tt></pre></blockquote>
    160 <h4 class="mansect"><a name="tag_20_148_17" id="tag_20_148_17"></a>EXAMPLES</h4>
    161 <blockquote>
    162 <p>None.</p>
    163 </blockquote>
    164 <h4 class="mansect"><a name="tag_20_148_18" id="tag_20_148_18"></a>RATIONALE</h4>
    165 <blockquote>
    166 <p>The output file format pseudo-<a href="../functions/printf.html"><i>printf</i>()</a> string differs from the System V version of
    167 <i>wc</i>:</p>
    168 <pre>
    169 <tt>"%7d%7d%7d %s\n"
    170 </tt></pre>
    171 <p>which produces possibly ambiguous and unparsable results for very large files, as it assumes no number shall exceed six
    172 digits.</p>
    173 <p>Some historical implementations use only &lt;space&gt;, &lt;tab&gt;, and &lt;newline&gt; as word separators. The equivalent of
    174 the ISO&nbsp;C standard <a href="../functions/isspace.html"><i>isspace</i>()</a> function is more appropriate.</p>
    175 <p>The <b>-c</b> option stands for &quot;character&quot; count, even though it counts bytes. This stems from the sometimes erroneous
    176 historical view that bytes and characters are the same size. Due to international requirements, the <b>-m</b> option (reminiscent
    177 of &quot;multi-byte&quot;) was added to obtain actual character counts.</p>
    178 <p>Early proposals only specified the results when input files were text files. The current specification more closely matches
    179 historical practice. (Bytes, words, and &lt;newline&gt; characters are counted separately and the results are written when an
    180 end-of-file is detected.)</p>
    181 <p>Historical implementations of the <i>wc</i> utility only accepted one argument to specify the options <b>-c</b>, <b>-l</b>, and
    182 <b>-w</b>. Some of them also had multiple occurrences of an option cause the corresponding count to be written multiple times and
    183 had the order of specification of the options affect the order of the fields on output, but did not document either of these.
    184 Because common usage either specifies no options or only one option, and because none of this was documented, the changes required
    185 by this volume of POSIX.1-2024 should not break many historical applications (and do not break any historical conforming
    186 applications).</p>
    187 </blockquote>
    188 <h4 class="mansect"><a name="tag_20_148_19" id="tag_20_148_19"></a>FUTURE DIRECTIONS</h4>
    189 <blockquote>
    190 <p>If this utility is directed to display a pathname that contains any bytes that have the encoded value of a &lt;newline&gt;
    191 character when &lt;newline&gt; is a terminator or separator in the output format being used, implementations are encouraged to
    192 treat this as an error. A future version of this standard may require implementations to treat this as an error.</p>
    193 </blockquote>
    194 <h4 class="mansect"><a name="tag_20_148_20" id="tag_20_148_20"></a>SEE ALSO</h4>
    195 <blockquote>
    196 <p><a href="../utilities/cksum.html#"><i>cksum</i></a></p>
    197 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href=
    198 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
    199 </blockquote>
    200 <h4 class="mansect"><a name="tag_20_148_21" id="tag_20_148_21"></a>CHANGE HISTORY</h4>
    201 <blockquote>
    202 <p>First released in Issue 2.</p>
    203 </blockquote>
    204 <h4 class="mansect"><a name="tag_20_148_22" id="tag_20_148_22"></a>Issue 7</h4>
    205 <blockquote>
    206 <p>Austin Group Interpretation 1003.1-2001 #092 is applied.</p>
    207 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    208 </blockquote>
    209 <h4 class="mansect"><a name="tag_20_148_23" id="tag_20_148_23"></a>Issue 8</h4>
    210 <blockquote>
    211 <p>Austin Group Defect 251 is applied, encouraging implementations to report an error if a utility is directed to display a
    212 pathname that contains any bytes that have the encoded value of a &lt;newline&gt; character when &lt;newline&gt; is a terminator or
    213 separator in the output format being used.</p>
    214 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    215 </blockquote>
    216 <div class="box"><em>End of informative text.</em></div>
    217 <hr>
    218 <p>&nbsp;</p>
    219 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    220 <hr size="2" noshade>
    221 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    222 POSIX™ is a Trademark of The IEEE.<br>
    223 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    224 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    225 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    226 ]</font></center>
    227 <hr size="2" noshade>
    228 <div class="NAVHEADER">
    229 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    230 <tr class="nav">
    231 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/wait.html" accesskey="P">&lt;&lt;&lt;
    232 Previous</a></td>
    233 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    234 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/what.html" accesskey="N">Next &gt;&gt;&gt;</a></td>
    235 </tr>
    236 </table>
    237 <hr align="left" width="100%"></div>
    238 </body>
    239 </html>