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

wc.1p (7866B)


  1. '\" et
  2. .TH WC "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. wc
  12. \(em word, line, and byte or character count
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. wc \fB[\fR-c|-m\fB] [\fR-lw\fB] [\fIfile\fR...\fB]\fR
  17. .fi
  18. .SH DESCRIPTION
  19. The
  20. .IR wc
  21. utility shall read one or more input files and, by default, write the
  22. number of
  23. <newline>
  24. characters, words, and bytes contained in each input file to the standard
  25. output.
  26. .P
  27. The utility also shall write a total count for all named files, if more
  28. than one input file is specified.
  29. .P
  30. The
  31. .IR wc
  32. utility shall consider a
  33. .IR word
  34. to be a non-zero-length string of characters delimited by white space.
  35. .SH OPTIONS
  36. The
  37. .IR wc
  38. utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
  39. .IR "Section 12.2" ", " "Utility Syntax Guidelines".
  40. .P
  41. The following options shall be supported:
  42. .IP "\fB\-c\fP" 10
  43. Write to the standard output the number of bytes in each input file.
  44. .IP "\fB\-l\fP" 10
  45. Write to the standard output the number of
  46. <newline>
  47. characters in each input file.
  48. .IP "\fB\-m\fP" 10
  49. Write to the standard output the number of characters in each input
  50. file.
  51. .IP "\fB\-w\fP" 10
  52. Write to the standard output the number of words in each input file.
  53. .P
  54. When any option is specified,
  55. .IR wc
  56. shall report only the information requested by the specified options.
  57. .SH OPERANDS
  58. The following operand shall be supported:
  59. .IP "\fIfile\fR" 10
  60. A pathname of an input file. If no
  61. .IR file
  62. operands are specified, the standard input shall be used.
  63. .SH STDIN
  64. The standard input shall be used if no
  65. .IR file
  66. operands are specified, and shall be used if a
  67. .IR file
  68. operand is
  69. .BR '\-'
  70. and the implementation treats the
  71. .BR '\-'
  72. as meaning standard input.
  73. Otherwise, the standard input shall not be used.
  74. See the INPUT FILES section.
  75. .SH "INPUT FILES"
  76. The input files may be of any type.
  77. .SH "ENVIRONMENT VARIABLES"
  78. The following environment variables shall affect the execution of
  79. .IR wc :
  80. .IP "\fILANG\fP" 10
  81. Provide a default value for the internationalization variables that are
  82. unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
  83. .IR "Section 8.2" ", " "Internationalization Variables"
  84. for the precedence of internationalization variables used to determine
  85. the values of locale categories.)
  86. .IP "\fILC_ALL\fP" 10
  87. If set to a non-empty string value, override the values of all the
  88. other internationalization variables.
  89. .IP "\fILC_CTYPE\fP" 10
  90. Determine the locale for the interpretation of sequences of bytes of
  91. text data as characters (for example, single-byte as opposed to
  92. multi-byte characters in arguments and input files) and which
  93. characters are defined as white-space characters.
  94. .IP "\fILC_MESSAGES\fP" 10
  95. .br
  96. Determine the locale that should be used to affect the format and
  97. contents of diagnostic messages written to standard error and
  98. informative messages written to standard output.
  99. .IP "\fINLSPATH\fP" 10
  100. Determine the location of message catalogs for the processing of
  101. .IR LC_MESSAGES .
  102. .SH "ASYNCHRONOUS EVENTS"
  103. Default.
  104. .SH STDOUT
  105. By default, the standard output shall contain an entry for each input
  106. file of the form:
  107. .sp
  108. .RS 4
  109. .nf
  110. "%d %d %d %s\en", <\fInewlines\fR>, <\fIwords\fR>, <\fIbytes\fR>, <\fIfile\fR>
  111. .fi
  112. .P
  113. .RE
  114. .P
  115. If the
  116. .BR \-m
  117. option is specified, the number of characters shall replace the
  118. <\fIbytes\fP> field in this format.
  119. .P
  120. If any options are specified and the
  121. .BR \-l
  122. option is not specified, the number of
  123. <newline>
  124. characters shall not be written.
  125. .P
  126. If any options are specified and the
  127. .BR \-w
  128. option is not specified, the number of words shall not be written.
  129. .P
  130. If any options are specified and neither
  131. .BR \-c
  132. nor
  133. .BR \-m
  134. is specified, the number of bytes or characters shall not be written.
  135. .P
  136. If no input
  137. .IR file
  138. operands are specified, no name shall be written and no
  139. <blank>
  140. characters preceding the pathname shall be written.
  141. .P
  142. If more than one input
  143. .IR file
  144. operand is specified, an additional line shall be written, of the same
  145. format as the other lines, except that the word
  146. .BR total
  147. (in the POSIX locale) shall be written instead of a pathname and the
  148. total of each column shall be written as appropriate. Such an
  149. additional line, if any, is written at the end of the output.
  150. .SH STDERR
  151. The standard error shall be used only for diagnostic messages.
  152. .SH "OUTPUT FILES"
  153. None.
  154. .SH "EXTENDED DESCRIPTION"
  155. None.
  156. .SH "EXIT STATUS"
  157. The following exit values shall be returned:
  158. .IP "\00" 6
  159. Successful completion.
  160. .IP >0 6
  161. An error occurred.
  162. .SH "CONSEQUENCES OF ERRORS"
  163. Default.
  164. .LP
  165. .IR "The following sections are informative."
  166. .SH "APPLICATION USAGE"
  167. The
  168. .BR \-m
  169. option is not a switch, but an option at the same level as
  170. .BR \-c .
  171. Thus, to produce the full default output with character counts instead
  172. of bytes, the command required is:
  173. .sp
  174. .RS 4
  175. .nf
  176. wc -mlw
  177. .fi
  178. .P
  179. .RE
  180. .SH EXAMPLES
  181. None.
  182. .SH RATIONALE
  183. The output file format pseudo-\c
  184. \fIprintf\fR()
  185. string differs from the System V version of
  186. .IR wc :
  187. .sp
  188. .RS 4
  189. .nf
  190. "%7d%7d%7d %s\en"
  191. .fi
  192. .P
  193. .RE
  194. .P
  195. which produces possibly ambiguous and unparsable results for very large
  196. files, as it assumes no number shall exceed six digits.
  197. .P
  198. Some historical implementations use only
  199. <space>,
  200. <tab>,
  201. and
  202. <newline>
  203. as word separators. The equivalent of the ISO\ C standard
  204. \fIisspace\fR()
  205. function is more appropriate.
  206. .P
  207. The
  208. .BR \-c
  209. option stands for ``character'' count, even though it counts bytes.
  210. This stems from the sometimes erroneous historical view that bytes and
  211. characters are the same size. Due to international requirements, the
  212. .BR \-m
  213. option (reminiscent of ``multi-byte'') was added to obtain actual
  214. character counts.
  215. .P
  216. Early proposals only specified the results when input files were text
  217. files. The current specification more closely matches historical
  218. practice. (Bytes, words, and
  219. <newline>
  220. characters are counted separately and the results are written when an
  221. end-of-file is detected.)
  222. .P
  223. Historical implementations of the
  224. .IR wc
  225. utility only accepted one argument to specify the options
  226. .BR \-c ,
  227. .BR \-l ,
  228. and
  229. .BR \-w .
  230. Some of them also had multiple occurrences of an option cause the
  231. corresponding count to be written multiple times and had the order of
  232. specification of the options affect the order of the fields on output,
  233. but did not document either of these. Because common usage either
  234. specifies no options or only one option, and because none of this was
  235. documented, the changes required by this volume of POSIX.1\(hy2017 should not break many
  236. historical applications (and do not break any historical conforming
  237. applications).
  238. .SH "FUTURE DIRECTIONS"
  239. None.
  240. .SH "SEE ALSO"
  241. .IR "\fIcksum\fR\^"
  242. .P
  243. The Base Definitions volume of POSIX.1\(hy2017,
  244. .IR "Chapter 8" ", " "Environment Variables",
  245. .IR "Section 12.2" ", " "Utility Syntax Guidelines"
  246. .\"
  247. .SH COPYRIGHT
  248. Portions of this text are reprinted and reproduced in electronic form
  249. from IEEE Std 1003.1-2017, Standard for Information Technology
  250. -- Portable Operating System Interface (POSIX), The Open Group Base
  251. Specifications Issue 7, 2018 Edition,
  252. Copyright (C) 2018 by the Institute of
  253. Electrical and Electronics Engineers, Inc and The Open Group.
  254. In the event of any discrepancy between this version and the original IEEE and
  255. The Open Group Standard, the original IEEE and The Open Group Standard
  256. is the referee document. The original Standard can be obtained online at
  257. http://www.opengroup.org/unix/online.html .
  258. .PP
  259. Any typographical or formatting errors that appear
  260. in this page are most likely
  261. to have been introduced during the conversion of the source files to
  262. man page format. To report such errors, see
  263. https://www.kernel.org/doc/man-pages/reporting_bugs.html .