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

head.1p (6170B)


  1. '\" et
  2. .TH HEAD "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. head
  12. \(em copy the first part of files
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. head \fB[\fR-n \fInumber\fB] [\fIfile\fR...\fB]\fR
  17. .fi
  18. .SH DESCRIPTION
  19. The
  20. .IR head
  21. utility shall copy its input files to the standard output, ending the
  22. output for each file at a designated point.
  23. .P
  24. Copying shall end at the point in each input file indicated by the
  25. .BR \-n
  26. .IR number
  27. option. The option-argument
  28. .IR number
  29. shall be counted in units of lines.
  30. .SH OPTIONS
  31. The
  32. .IR head
  33. utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
  34. .IR "Section 12.2" ", " "Utility Syntax Guidelines".
  35. .P
  36. The following option shall be supported:
  37. .IP "\fB\-n\ \fInumber\fR" 10
  38. The first
  39. .IR number
  40. lines of each input file shall be copied to standard output. The
  41. application shall ensure that the
  42. .IR number
  43. option-argument is a positive decimal integer.
  44. .P
  45. When a file contains less than
  46. .IR number
  47. lines, it shall be copied to standard output in its entirety. This
  48. shall not be an error.
  49. .P
  50. If no options are specified,
  51. .IR head
  52. shall act as if
  53. .BR "\-n 10"
  54. had been specified.
  55. .SH OPERANDS
  56. The following operand shall be supported:
  57. .IP "\fIfile\fR" 10
  58. A pathname of an input file. If no
  59. .IR file
  60. operands are specified, the standard input shall be used.
  61. .SH STDIN
  62. The standard input shall be used if no
  63. .IR file
  64. operands are specified, and shall be used if a
  65. .IR file
  66. operand is
  67. .BR '\-'
  68. and the implementation treats the
  69. .BR '\-'
  70. as meaning standard input.
  71. Otherwise, the standard input shall not be used.
  72. See the INPUT FILES section.
  73. .SH "INPUT FILES"
  74. Input files shall be text files, but the line length is not restricted
  75. to
  76. {LINE_MAX}
  77. bytes.
  78. .SH "ENVIRONMENT VARIABLES"
  79. The following environment variables shall affect the execution of
  80. .IR head :
  81. .IP "\fILANG\fP" 10
  82. Provide a default value for the internationalization variables that are
  83. unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
  84. .IR "Section 8.2" ", " "Internationalization Variables"
  85. for the precedence of internationalization variables used to determine
  86. the values of locale categories.)
  87. .IP "\fILC_ALL\fP" 10
  88. If set to a non-empty string value, override the values of all the
  89. other internationalization variables.
  90. .IP "\fILC_CTYPE\fP" 10
  91. Determine the locale for the interpretation of sequences of bytes of
  92. text data as characters (for example, single-byte as opposed to
  93. multi-byte characters in arguments and input files).
  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.
  98. .IP "\fINLSPATH\fP" 10
  99. Determine the location of message catalogs for the processing of
  100. .IR LC_MESSAGES .
  101. .SH "ASYNCHRONOUS EVENTS"
  102. Default.
  103. .SH STDOUT
  104. The standard output shall contain designated portions of the input
  105. files.
  106. .P
  107. If multiple
  108. .IR file
  109. operands are specified,
  110. .IR head
  111. shall precede the output for each with the header:
  112. .sp
  113. .RS 4
  114. .nf
  115. "\en==> %s <==\en", <\fIpathname\fR>
  116. .fi
  117. .P
  118. .RE
  119. .P
  120. except that the first header written shall not include the initial
  121. <newline>.
  122. .SH STDERR
  123. The standard error shall be used only for diagnostic messages.
  124. .SH "OUTPUT FILES"
  125. None.
  126. .SH "EXTENDED DESCRIPTION"
  127. None.
  128. .SH "EXIT STATUS"
  129. The following exit values shall be returned:
  130. .IP "\00" 6
  131. Successful completion.
  132. .IP >0 6
  133. An error occurred.
  134. .SH "CONSEQUENCES OF ERRORS"
  135. Default.
  136. .LP
  137. .IR "The following sections are informative."
  138. .SH "APPLICATION USAGE"
  139. When using
  140. .IR head
  141. to process pathnames, it is recommended that LC_ALL, or at least
  142. LC_CTYPE and LC_COLLATE, are set to POSIX or C in the environment,
  143. since pathnames can contain byte sequences that do not form valid
  144. characters in some locales, in which case the utility's behavior would
  145. be undefined. In the POSIX locale each byte is a valid single-byte
  146. character, and therefore this problem is avoided.
  147. .SH EXAMPLES
  148. To write the first ten lines of all files (except those with a leading
  149. period) in the directory:
  150. .sp
  151. .RS 4
  152. .nf
  153. head -- *
  154. .fi
  155. .P
  156. .RE
  157. .SH RATIONALE
  158. Although it is possible to simulate
  159. .IR head
  160. with
  161. .IR sed
  162. 10q for a single file, the standard developers decided that the
  163. popularity of
  164. .IR head
  165. on historical BSD systems warranted its inclusion alongside
  166. .IR tail .
  167. .P
  168. POSIX.1\(hy2008 version of
  169. .IR head
  170. follows the Utility Syntax Guidelines. The
  171. .BR \-n
  172. option was added to this new interface so that
  173. .IR head
  174. and
  175. .IR tail
  176. would be more logically related. Earlier versions of this standard
  177. allowed a
  178. .BR \-number
  179. option. This form is no longer specified by POSIX.1\(hy2008 but may
  180. be present in some implementations.
  181. .P
  182. There is no
  183. .BR \-c
  184. option (as there is in
  185. .IR tail )
  186. because it is not historical practice and because other utilities in
  187. \&this volume of POSIX.1\(hy2017 provide similar functionality.
  188. .SH "FUTURE DIRECTIONS"
  189. None.
  190. .SH "SEE ALSO"
  191. .IR "\fIsed\fR\^",
  192. .IR "\fItail\fR\^"
  193. .P
  194. The Base Definitions volume of POSIX.1\(hy2017,
  195. .IR "Chapter 8" ", " "Environment Variables",
  196. .IR "Section 12.2" ", " "Utility Syntax Guidelines"
  197. .\"
  198. .SH COPYRIGHT
  199. Portions of this text are reprinted and reproduced in electronic form
  200. from IEEE Std 1003.1-2017, Standard for Information Technology
  201. -- Portable Operating System Interface (POSIX), The Open Group Base
  202. Specifications Issue 7, 2018 Edition,
  203. Copyright (C) 2018 by the Institute of
  204. Electrical and Electronics Engineers, Inc and The Open Group.
  205. In the event of any discrepancy between this version and the original IEEE and
  206. The Open Group Standard, the original IEEE and The Open Group Standard
  207. is the referee document. The original Standard can be obtained online at
  208. http://www.opengroup.org/unix/online.html .
  209. .PP
  210. Any typographical or formatting errors that appear
  211. in this page are most likely
  212. to have been introduced during the conversion of the source files to
  213. man page format. To report such errors, see
  214. https://www.kernel.org/doc/man-pages/reporting_bugs.html .