logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

du.1p (9945B)


  1. '\" et
  2. .TH DU "1P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. du
  12. \(em estimate file space usage
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. du \fB[\fR-a|-s\fB] [\fR-kx\fB] [\fR-H|-L\fB] [\fIfile\fR...\fB]\fR
  17. .fi
  18. .SH DESCRIPTION
  19. By default, the
  20. .IR du
  21. utility shall write to standard output the size of the file space
  22. allocated to, and the size of the file space allocated to each
  23. subdirectory of, the file hierarchy rooted in each of the specified
  24. files. By default, when a symbolic link is encountered on the command
  25. line or in the file hierarchy,
  26. .IR du
  27. shall count the size of the symbolic link (rather than the file
  28. referenced by the link), and shall not follow the link to another
  29. portion of the file hierarchy. The size of the file space allocated to
  30. a file of type directory shall be defined as the sum total of space
  31. allocated to all files in the file hierarchy rooted in the directory
  32. plus the space allocated to the directory itself.
  33. .P
  34. When
  35. .IR du
  36. cannot
  37. \fIstat\fR()
  38. files or
  39. \fIstat\fR()
  40. or read directories, it shall report an error condition and the final
  41. exit status is affected. A file that occurs multiple times under one
  42. file operand and that has a link count greater than 1 shall be counted
  43. and written for only one entry. It is implementation-defined whether a
  44. file that has a link count no greater than 1 is counted and written
  45. just once, or is counted and written for each occurrence. It is
  46. implementation-defined whether a file that occurs under one file
  47. operand is counted for other file operands. The directory entry
  48. that is selected in the report is unspecified. By default, file
  49. sizes shall be written in 512-byte units, rounded up to the next
  50. 512-byte unit.
  51. .SH OPTIONS
  52. The
  53. .IR du
  54. utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
  55. .IR "Section 12.2" ", " "Utility Syntax Guidelines".
  56. .P
  57. The following options shall be supported:
  58. .IP "\fB\-a\fP" 10
  59. In addition to the default output, report the size of each file not of
  60. type directory in the file hierarchy rooted in the specified file.
  61. The
  62. .BR \-a
  63. option shall not affect whether non-directories given as
  64. .IR file
  65. operands are listed.
  66. .IP "\fB\-H\fP" 10
  67. If a symbolic link is specified on the command line,
  68. .IR du
  69. shall count the size of the file or file hierarchy referenced by the
  70. link.
  71. .IP "\fB\-k\fP" 10
  72. Write the files sizes in units of 1\|024 bytes, rather than the default
  73. 512-byte units.
  74. .IP "\fB\-L\fP" 10
  75. If a symbolic link is specified on the command line or encountered
  76. during the traversal of a file hierarchy,
  77. .IR du
  78. shall count the size of the file or file hierarchy referenced by the
  79. link.
  80. .IP "\fB\-s\fP" 10
  81. Instead of the default output, report only the total sum for each of
  82. the specified files.
  83. .IP "\fB\-x\fP" 10
  84. When evaluating file sizes, evaluate only those files that have the
  85. same device as the file specified by the
  86. .IR file
  87. operand.
  88. .P
  89. Specifying more than one of the mutually-exclusive options
  90. .BR \-H
  91. and
  92. .BR \-L
  93. shall not be considered an error. The last option specified shall
  94. determine the behavior of the utility.
  95. .SH OPERANDS
  96. The following operand shall be supported:
  97. .IP "\fIfile\fR" 10
  98. The pathname of a file whose size is to be written. If no
  99. .IR file
  100. is specified, the current directory shall be used.
  101. .SH STDIN
  102. Not used.
  103. .SH "INPUT FILES"
  104. None.
  105. .SH "ENVIRONMENT VARIABLES"
  106. The following environment variables shall affect the execution of
  107. .IR du :
  108. .IP "\fILANG\fP" 10
  109. Provide a default value for the internationalization variables that are
  110. unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
  111. .IR "Section 8.2" ", " "Internationalization Variables"
  112. for the precedence of internationalization variables used to determine
  113. the values of locale categories.)
  114. .IP "\fILC_ALL\fP" 10
  115. If set to a non-empty string value, override the values of all the
  116. other internationalization variables.
  117. .IP "\fILC_CTYPE\fP" 10
  118. Determine the locale for the interpretation of sequences of bytes of
  119. text data as characters (for example, single-byte as opposed to
  120. multi-byte characters in arguments).
  121. .IP "\fILC_MESSAGES\fP" 10
  122. .br
  123. Determine the locale that should be used to affect the format and
  124. contents of diagnostic messages written to standard error.
  125. .IP "\fINLSPATH\fP" 10
  126. Determine the location of message catalogs for the processing of
  127. .IR LC_MESSAGES .
  128. .SH "ASYNCHRONOUS EVENTS"
  129. Default.
  130. .SH STDOUT
  131. The output from
  132. .IR du
  133. shall consist of the amount of space allocated to a file and the
  134. name of the file, in the following format:
  135. .sp
  136. .RS 4
  137. .nf
  138. "%d %s\en", <\fIsize\fR>, <\fIpathname\fR>
  139. .fi
  140. .P
  141. .RE
  142. .SH STDERR
  143. The standard error shall be used only for diagnostic messages.
  144. .SH "OUTPUT FILES"
  145. None.
  146. .SH "EXTENDED DESCRIPTION"
  147. None.
  148. .SH "EXIT STATUS"
  149. The following exit values shall be returned:
  150. .IP "\00" 6
  151. Successful completion.
  152. .IP >0 6
  153. An error occurred.
  154. .SH "CONSEQUENCES OF ERRORS"
  155. Default.
  156. .LP
  157. .IR "The following sections are informative."
  158. .SH "APPLICATION USAGE"
  159. None.
  160. .SH EXAMPLES
  161. None.
  162. .SH RATIONALE
  163. The use of 512-byte units is historical practice and maintains
  164. compatibility with
  165. .IR ls
  166. and other utilities in this volume of POSIX.1\(hy2017. This does not mandate that the
  167. file system itself be based on 512-byte blocks. The
  168. .BR \-k
  169. option was added as a compromise measure. It was agreed by the standard
  170. developers that 512 bytes was the best default unit because of its
  171. complete historical consistency on System V (\fIversus\fP the mixed
  172. 512/1\|024-byte usage on BSD systems), and that a
  173. .BR \-k
  174. option to switch to 1\|024-byte units was a good compromise. Users who
  175. prefer the 1\|024-byte quantity can easily alias
  176. .IR du
  177. to
  178. .IR du
  179. .BR \-k
  180. without breaking the many historical scripts relying on the 512-byte
  181. units.
  182. .P
  183. The
  184. .BR \-b
  185. option was added to an early proposal to provide a resolution to the
  186. situation where System V and BSD systems give figures for file sizes in
  187. .IR blocks ,
  188. which is an implementation-defined concept. (In common usage, the
  189. block size is 512 bytes for System V and 1\|024 bytes for BSD systems.)
  190. However,
  191. .BR \-b
  192. was later deleted, since the default was eventually decided as 512-byte
  193. units.
  194. .P
  195. Historical file systems provided no way to obtain exact figures for the
  196. space allocation given to files. There are two known areas of
  197. inaccuracies in historical file systems: cases of
  198. .IR "indirect blocks"
  199. being used by the file system or
  200. .IR "sparse"
  201. files yielding incorrectly high values. An indirect block is space used
  202. by the file system in the storage of the file, but that need not be
  203. counted in the space allocated to the file. A
  204. .IR sparse
  205. file is one in which an
  206. \fIlseek\fR()
  207. call has been made to a position beyond the end of the file and data
  208. has subsequently been written at that point. A file system need not
  209. allocate all the intervening zero-filled blocks to such a file. It is
  210. up to the implementation to define exactly how accurate its methods
  211. are.
  212. .P
  213. The
  214. .BR \-a
  215. and
  216. .BR \-s
  217. options were mutually-exclusive in the original version of
  218. .IR du .
  219. The POSIX Shell and Utilities description is implied by the language in
  220. the SVID where
  221. .BR \-s
  222. is described as causing ``only the grand total'' to be reported. Some
  223. systems may produce output for
  224. .BR \-sa ,
  225. but a Strictly Conforming POSIX Shell and Utilities Application cannot
  226. use that combination.
  227. .P
  228. The
  229. .BR \-a
  230. and
  231. .BR \-s
  232. options were adopted from the SVID except that the System V behavior of
  233. not listing non-directories explicitly given as operands, unless the
  234. .BR \-a
  235. option is specified, was considered a bug; the BSD-based behavior
  236. (report for all operands) is mandated. The default behavior of
  237. .IR du
  238. in the SVID with regard to reporting the failure to read files (it
  239. produces no messages) was considered counter-intuitive, and thus it was
  240. specified that the POSIX Shell and Utilities default behavior shall be
  241. to produce such messages. These messages can be turned off with shell
  242. redirection to achieve the System V behavior.
  243. .P
  244. The
  245. .BR \-x
  246. option is historical practice on recent BSD systems. It has been
  247. adopted by this volume of POSIX.1\(hy2017 because there was no other historical method of
  248. limiting the
  249. .IR du
  250. search to a single file hierarchy. This limitation of the search is
  251. necessary to make it possible to obtain file space usage information
  252. about a file system on which other file systems are mounted, without
  253. having to resort to a lengthy
  254. .IR find
  255. and
  256. .IR awk
  257. script.
  258. .SH "FUTURE DIRECTIONS"
  259. A future version of this standard may require that a file that occurs
  260. multiple times shall be counted and written for only one entry, even
  261. if the occurrences are under different file operands.
  262. .SH "SEE ALSO"
  263. .IR "\fIls\fR\^"
  264. .P
  265. The Base Definitions volume of POSIX.1\(hy2017,
  266. .IR "Chapter 8" ", " "Environment Variables",
  267. .IR "Section 12.2" ", " "Utility Syntax Guidelines"
  268. .P
  269. The System Interfaces volume of POSIX.1\(hy2017,
  270. .IR "\fIfstatat\fR\^(\|)"
  271. .\"
  272. .SH COPYRIGHT
  273. Portions of this text are reprinted and reproduced in electronic form
  274. from IEEE Std 1003.1-2017, Standard for Information Technology
  275. -- Portable Operating System Interface (POSIX), The Open Group Base
  276. Specifications Issue 7, 2018 Edition,
  277. Copyright (C) 2018 by the Institute of
  278. Electrical and Electronics Engineers, Inc and The Open Group.
  279. In the event of any discrepancy between this version and the original IEEE and
  280. The Open Group Standard, the original IEEE and The Open Group Standard
  281. is the referee document. The original Standard can be obtained online at
  282. http://www.opengroup.org/unix/online.html .
  283. .PP
  284. Any typographical or formatting errors that appear
  285. in this page are most likely
  286. to have been introduced during the conversion of the source files to
  287. man page format. To report such errors, see
  288. https://www.kernel.org/doc/man-pages/reporting_bugs.html .