isposix

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

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

du.html (16355B)


      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>du</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/dirname.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/echo.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="du" id="du"></a> <a name="tag_20_36" id="tag_20_36"></a><!-- du -->
     28 <h4 class="mansect"><a name="tag_20_36_01" id="tag_20_36_01"></a>NAME</h4>
     29 <blockquote>du — estimate file space usage</blockquote>
     30 <h4 class="mansect"><a name="tag_20_36_02" id="tag_20_36_02"></a>SYNOPSIS</h4>
     31 <blockquote class="synopsis">
     32 <p><code><tt>du</tt> <b>[</b><tt>-a|-s</tt><b>] [</b><tt>-kx</tt><b>] [</b><tt>-H|-L</tt><b>] [</b><i>file</i><tt>...</tt><b>]</b></code></p>
     33 </blockquote>
     34 <h4 class="mansect"><a name="tag_20_36_03" id="tag_20_36_03"></a>DESCRIPTION</h4>
     35 <blockquote>
     36 <p>By default, the <i>du</i> utility shall write to standard output the size of the file space allocated to, and the size of the
     37 file space allocated to each subdirectory of, the file hierarchy rooted in each of the specified files. By default, when a symbolic
     38 link is encountered on the command line or in the file hierarchy, <i>du</i> shall count the size of the symbolic link (rather than
     39 the file referenced by the link), and shall not follow the link to another portion of the file hierarchy. The size of the file
     40 space allocated to a file of type directory shall be defined as the sum total of space allocated to all files in the file hierarchy
     41 rooted in the directory plus the space allocated to the directory itself.</p>
     42 <p>When <i>du</i> cannot <a href="../functions/stat.html"><i>stat</i>()</a> files or <a href=
     43 "../functions/stat.html"><i>stat</i>()</a> or read directories, it shall report an error condition and the final exit status is
     44 affected. A file that occurs multiple times shall be counted and written for only one entry, even if the occurrences are under
     45 different file operands. The directory entry that is selected in the report is unspecified. By default, file sizes shall be written
     46 in 512-byte units, rounded up to the next 512-byte unit.</p>
     47 </blockquote>
     48 <h4 class="mansect"><a name="tag_20_36_04" id="tag_20_36_04"></a>OPTIONS</h4>
     49 <blockquote>
     50 <p>The <i>du</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     51 Guidelines</i></a> .</p>
     52 <p>The following options shall be supported:</p>
     53 <dl compact>
     54 <dd></dd>
     55 <dt><b>-a</b></dt>
     56 <dd>In addition to the default output, report the size of each file not of type directory in the file hierarchy rooted in the
     57 specified file. The <b>-a</b> option shall not affect whether non-directories given as <i>file</i> operands are listed.</dd>
     58 <dt><b>-H</b></dt>
     59 <dd>If a symbolic link is specified on the command line, <i>du</i> shall count the size of the file or file hierarchy referenced by
     60 the link.</dd>
     61 <dt><b>-k</b></dt>
     62 <dd>Write the files sizes in units of 1024 bytes, rather than the default 512-byte units.</dd>
     63 <dt><b>-L</b></dt>
     64 <dd>If a symbolic link is specified on the command line or encountered during the traversal of a file hierarchy, <i>du</i> shall
     65 count the size of the file or file hierarchy referenced by the link.</dd>
     66 <dt><b>-s</b></dt>
     67 <dd>Instead of the default output, report only the total sum for each of the specified files.</dd>
     68 <dt><b>-x</b></dt>
     69 <dd>When evaluating file sizes, evaluate only those files that have the same device as the file specified by the <i>file</i>
     70 operand.</dd>
     71 </dl>
     72 <p>Specifying more than one of the mutually-exclusive options <b>-H</b> and <b>-L</b> shall not be considered an error. The last
     73 option specified shall determine the behavior of the utility.</p>
     74 </blockquote>
     75 <h4 class="mansect"><a name="tag_20_36_05" id="tag_20_36_05"></a>OPERANDS</h4>
     76 <blockquote>
     77 <p>The following operand shall be supported:</p>
     78 <dl compact>
     79 <dd></dd>
     80 <dt><i>file</i></dt>
     81 <dd>The pathname of a file whose size is to be written. If no <i>file</i> is specified, the current directory shall be used.</dd>
     82 </dl>
     83 </blockquote>
     84 <h4 class="mansect"><a name="tag_20_36_06" id="tag_20_36_06"></a>STDIN</h4>
     85 <blockquote>
     86 <p>Not used.</p>
     87 </blockquote>
     88 <h4 class="mansect"><a name="tag_20_36_07" id="tag_20_36_07"></a>INPUT FILES</h4>
     89 <blockquote>
     90 <p>None.</p>
     91 </blockquote>
     92 <h4 class="mansect"><a name="tag_20_36_08" id="tag_20_36_08"></a>ENVIRONMENT VARIABLES</h4>
     93 <blockquote>
     94 <p>The following environment variables shall affect the execution of <i>du</i>:</p>
     95 <dl compact>
     96 <dd></dd>
     97 <dt><i>LANG</i></dt>
     98 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
     99 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
    100 variables used to determine the values of locale categories.)</dd>
    101 <dt><i>LC_ALL</i></dt>
    102 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
    103 <dt><i>LC_CTYPE</i></dt>
    104 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
    105 opposed to multi-byte characters in arguments).</dd>
    106 <dt><i>LC_MESSAGES</i></dt>
    107 <dd><br>
    108 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd>
    109 <dt><i>NLSPATH</i></dt>
    110 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    111 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
    112 "0"></dd>
    113 </dl>
    114 </blockquote>
    115 <h4 class="mansect"><a name="tag_20_36_09" id="tag_20_36_09"></a>ASYNCHRONOUS EVENTS</h4>
    116 <blockquote>
    117 <p>Default.</p>
    118 </blockquote>
    119 <h4 class="mansect"><a name="tag_20_36_10" id="tag_20_36_10"></a>STDOUT</h4>
    120 <blockquote>
    121 <p>The output from <i>du</i> shall consist of the amount of space allocated to a file and the name of the file, in the following
    122 format:</p>
    123 <pre>
    124 <tt>"%d %s\n", &lt;</tt><i>size</i><tt>&gt;, &lt;</tt><i>pathname</i><tt>&gt;
    125 </tt></pre></blockquote>
    126 <h4 class="mansect"><a name="tag_20_36_11" id="tag_20_36_11"></a>STDERR</h4>
    127 <blockquote>
    128 <p>The standard error shall be used only for diagnostic messages.</p>
    129 </blockquote>
    130 <h4 class="mansect"><a name="tag_20_36_12" id="tag_20_36_12"></a>OUTPUT FILES</h4>
    131 <blockquote>
    132 <p>None.</p>
    133 </blockquote>
    134 <h4 class="mansect"><a name="tag_20_36_13" id="tag_20_36_13"></a>EXTENDED DESCRIPTION</h4>
    135 <blockquote>
    136 <p>None.</p>
    137 </blockquote>
    138 <h4 class="mansect"><a name="tag_20_36_14" id="tag_20_36_14"></a>EXIT STATUS</h4>
    139 <blockquote>
    140 <p>The following exit values shall be returned:</p>
    141 <dl compact>
    142 <dd></dd>
    143 <dt>&nbsp;0</dt>
    144 <dd>Successful completion.</dd>
    145 <dt>&gt;0</dt>
    146 <dd>An error occurred.</dd>
    147 </dl>
    148 </blockquote>
    149 <h4 class="mansect"><a name="tag_20_36_15" id="tag_20_36_15"></a>CONSEQUENCES OF ERRORS</h4>
    150 <blockquote>
    151 <p>Default.</p>
    152 </blockquote>
    153 <hr>
    154 <div class="box"><em>The following sections are informative.</em></div>
    155 <h4 class="mansect"><a name="tag_20_36_16" id="tag_20_36_16"></a>APPLICATION USAGE</h4>
    156 <blockquote>
    157 <p>None.</p>
    158 </blockquote>
    159 <h4 class="mansect"><a name="tag_20_36_17" id="tag_20_36_17"></a>EXAMPLES</h4>
    160 <blockquote>
    161 <p>None.</p>
    162 </blockquote>
    163 <h4 class="mansect"><a name="tag_20_36_18" id="tag_20_36_18"></a>RATIONALE</h4>
    164 <blockquote>
    165 <p>The use of 512-byte units is historical practice and maintains compatibility with <a href="../utilities/ls.html"><i>ls</i></a>
    166 and other utilities in this volume of POSIX.1-2024. This does not mandate that the file system itself be based on 512-byte blocks.
    167 The <b>-k</b> option was added as a compromise measure. It was agreed by the standard developers that 512 bytes was the best
    168 default unit because of its complete historical consistency on System V (<i>versus</i> the mixed 512/1024-byte usage on BSD
    169 systems), and that a <b>-k</b> option to switch to 1024-byte units was a good compromise. Users who prefer the 1024-byte quantity
    170 can easily alias <i>du</i> to <i>du</i> <b>-k</b> without breaking the many historical scripts relying on the 512-byte units.</p>
    171 <p>The <b>-b</b> option was added to an early proposal to provide a resolution to the situation where System V and BSD systems give
    172 figures for file sizes in <i>blocks</i>, which is an implementation-defined concept. (In common usage, the block size is 512 bytes
    173 for System V and 1024 bytes for BSD systems.) However, <b>-b</b> was later deleted, since the default was eventually decided as
    174 512-byte units.</p>
    175 <p>Historical file systems provided no way to obtain exact figures for the space allocation given to files. There are two known
    176 areas of inaccuracies in historical file systems: cases of <i>indirect blocks</i> being used by the file system or <i>sparse</i>
    177 files yielding incorrectly high values. An indirect block is space used by the file system in the storage of the file, but that
    178 need not be counted in the space allocated to the file. A <i>sparse</i> file is one in which an <a href=
    179 "../functions/lseek.html"><i>lseek</i>()</a> call has been made to a position beyond the end of the file and data has subsequently
    180 been written at that point. A file system need not allocate all the intervening zero-filled blocks to such a file. It is up to the
    181 implementation to define exactly how accurate its methods are.</p>
    182 <p>The <b>-a</b> and <b>-s</b> options were mutually-exclusive in the original version of <i>du</i>. The POSIX Shell and Utilities
    183 description is implied by the language in the SVID where <b>-s</b> is described as causing &quot;only the grand total&quot; to be reported.
    184 Some systems may produce output for <b>-sa</b>, but a Strictly Conforming POSIX Shell and Utilities Application cannot use that
    185 combination.</p>
    186 <p>The <b>-a</b> and <b>-s</b> options were adopted from the SVID except that the System V behavior of not listing non-directories
    187 explicitly given as operands, unless the <b>-a</b> option is specified, was considered a bug; the BSD-based behavior (report for
    188 all operands) is mandated. The default behavior of <i>du</i> in the SVID with regard to reporting the failure to read files (it
    189 produces no messages) was considered counter-intuitive, and thus it was specified that the POSIX Shell and Utilities default
    190 behavior shall be to produce such messages. These messages can be turned off with shell redirection to achieve the System V
    191 behavior.</p>
    192 <p>The <b>-x</b> option is historical practice on recent BSD systems. It has been adopted by this volume of POSIX.1-2024 because
    193 there was no other historical method of limiting the <i>du</i> search to a single file hierarchy. This limitation of the search is
    194 necessary to make it possible to obtain file space usage information about a file system on which other file systems are mounted,
    195 without having to resort to a lengthy <a href="../utilities/find.html"><i>find</i></a> and <a href=
    196 "../utilities/awk.html"><i>awk</i></a> script.</p>
    197 <p>The use of the <b>-L</b> option, or of multiple <i>file</i> operands, requires that <i>du</i> track all file entries
    198 encountered, even with a link count of one. However, when <b>-L</b> is not used and only a single <i>file</i> operand is given, an
    199 implementation can optimize by only tracking files with a link count greater than one, since in that scenario, those are the only
    200 files that could be encountered more than once.</p>
    201 </blockquote>
    202 <h4 class="mansect"><a name="tag_20_36_19" id="tag_20_36_19"></a>FUTURE DIRECTIONS</h4>
    203 <blockquote>
    204 <p>If this utility is directed to display a pathname that contains any bytes that have the encoded value of a &lt;newline&gt;
    205 character when &lt;newline&gt; is a terminator or separator in the output format being used, implementations are encouraged to
    206 treat this as an error. A future version of this standard may require implementations to treat this as an error.</p>
    207 </blockquote>
    208 <h4 class="mansect"><a name="tag_20_36_20" id="tag_20_36_20"></a>SEE ALSO</h4>
    209 <blockquote>
    210 <p><a href="../utilities/ls.html#"><i>ls</i></a></p>
    211 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href=
    212 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
    213 <p>XSH <a href="../functions/fstatat.html#"><i>fstatat</i></a></p>
    214 </blockquote>
    215 <h4 class="mansect"><a name="tag_20_36_21" id="tag_20_36_21"></a>CHANGE HISTORY</h4>
    216 <blockquote>
    217 <p>First released in Issue 2.</p>
    218 </blockquote>
    219 <h4 class="mansect"><a name="tag_20_36_22" id="tag_20_36_22"></a>Issue 6</h4>
    220 <blockquote>
    221 <p>This utility is marked as part of the User Portability Utilities option.</p>
    222 <p>The APPLICATION USAGE section is added.</p>
    223 <p>The obsolescent <b>-r</b> option is removed.</p>
    224 <p>The Open Group Corrigendum U025/3 is applied. The <i>du</i> utility is reinstated, as it had incorrectly been marked LEGACY in
    225 Issue 5.</p>
    226 <p>The <b>-H</b> and <b>-L</b> options for symbolic links are added as described in the IEEE&nbsp;P1003.2b draft standard.</p>
    227 </blockquote>
    228 <h4 class="mansect"><a name="tag_20_36_23" id="tag_20_36_23"></a>Issue 7</h4>
    229 <blockquote>
    230 <p>The <i>du</i> utility is moved from the User Portability Utilities option to the Base. User Portability Utilities is now an
    231 option for interactive utilities.</p>
    232 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    233 <p>POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0089 [527] is applied.</p>
    234 </blockquote>
    235 <h4 class="mansect"><a name="tag_20_36_24" id="tag_20_36_24"></a>Issue 8</h4>
    236 <blockquote>
    237 <p>Austin Group Defect 251 is applied, encouraging implementations to report an error if a utility is directed to display a
    238 pathname that contains any bytes that have the encoded value of a &lt;newline&gt; character when &lt;newline&gt; is a terminator or
    239 separator in the output format being used.</p>
    240 <p>Austin Group Defect 539 is applied, requiring a file that occurs multiple times to be counted and written for only one
    241 entry.</p>
    242 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    243 </blockquote>
    244 <div class="box"><em>End of informative text.</em></div>
    245 <hr>
    246 <p>&nbsp;</p>
    247 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    248 <hr size="2" noshade>
    249 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    250 POSIX™ is a Trademark of The IEEE.<br>
    251 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    252 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    253 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    254 ]</font></center>
    255 <hr size="2" noshade>
    256 <div class="NAVHEADER">
    257 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    258 <tr class="nav">
    259 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/dirname.html" accesskey="P">&lt;&lt;&lt;
    260 Previous</a></td>
    261 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    262 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/echo.html" accesskey="N">Next &gt;&gt;&gt;</a></td>
    263 </tr>
    264 </table>
    265 <hr align="left" width="100%"></div>
    266 </body>
    267 </html>