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

tail.1p (10503B)


  1. '\" et
  2. .TH TAIL "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. tail
  12. \(em copy the last part of a file
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. tail \fB[\fR-f\fB] [\fR-c \fInumber\fR|-n \fInumber\fB] [\fIfile\fB]\fR
  17. .fi
  18. .SH DESCRIPTION
  19. The
  20. .IR tail
  21. utility shall copy its input file to the standard output beginning at a
  22. designated place.
  23. .P
  24. Copying shall begin at the point in the file indicated by the
  25. .BR \-c
  26. .IR number
  27. or
  28. .BR \-n
  29. .IR number
  30. options. The option-argument
  31. .IR number
  32. shall be counted in units of lines or bytes, according to the options
  33. .BR \-n
  34. and
  35. .BR \-c .
  36. Both line and byte counts start from 1.
  37. .P
  38. Tails relative to the end of the file may be saved in an internal
  39. buffer, and thus may be limited in length. Such a buffer, if any,
  40. shall be no smaller than
  41. {LINE_MAX}*10
  42. bytes.
  43. .SH OPTIONS
  44. The
  45. .IR tail
  46. utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
  47. .IR "Section 12.2" ", " "Utility Syntax Guidelines",
  48. except that
  49. .BR '\(pl'
  50. may be recognized as an option delimiter as well as
  51. .BR '\-' .
  52. .P
  53. The following options shall be supported:
  54. .IP "\fB\-c\ \fInumber\fR" 10
  55. The application shall ensure that the
  56. .IR number
  57. option-argument is a decimal integer, optionally including a sign.
  58. The sign shall affect the location in the file, measured in bytes,
  59. to begin the copying:
  60. .TS
  61. center tab(@) box;
  62. cB | cB
  63. cf5 | l.
  64. Sign@Copying Starts
  65. _
  66. +@Relative to the beginning of the file.
  67. \-@Relative to the end of the file.
  68. \fInone\fP@Relative to the end of the file.
  69. .TE
  70. .RS 10
  71. .P
  72. The application shall ensure that if the sign of the
  73. .IR number
  74. option-argument is
  75. .BR '\(pl' ,
  76. the
  77. .IR number
  78. option-argument is a non-zero decimal integer.
  79. .P
  80. The origin for counting shall be 1; that is,
  81. .BR \-c
  82. +1 represents the first byte of the file,
  83. .BR \-c
  84. \-1 the last.
  85. .RE
  86. .IP "\fB\-f\fP" 10
  87. If the input file is a regular file or if the
  88. .IR file
  89. operand specifies a FIFO, do not terminate after the last line of the
  90. input file has been copied, but read and copy further bytes from the
  91. input file when they become available. If no
  92. .IR file
  93. operand is specified and standard input is a pipe or FIFO, the
  94. .BR \-f
  95. option shall be ignored. If the input file is not a FIFO, pipe, or
  96. regular file, it is unspecified whether or not the
  97. .BR \-f
  98. option shall be ignored.
  99. .IP "\fB\-n\ \fInumber\fR" 10
  100. This option shall be equivalent to
  101. .BR \-c
  102. .IR number ,
  103. except the starting location in the file shall be measured in lines
  104. instead of bytes. The origin for counting shall be 1; that is,
  105. .BR \-n
  106. +1 represents the first line of the file,
  107. .BR \-n
  108. \-1 the last.
  109. .P
  110. If neither
  111. .BR \-c
  112. nor
  113. .BR \-n
  114. is specified,
  115. .BR \-n
  116. 10 shall be assumed.
  117. .SH OPERANDS
  118. The following operand shall be supported:
  119. .IP "\fIfile\fR" 10
  120. A pathname of an input file. If no
  121. .IR file
  122. operand is specified, the standard input shall be used.
  123. .SH STDIN
  124. The standard input shall be used if no
  125. .IR file
  126. operand is specified, and shall be used if the
  127. .IR file
  128. operand is
  129. .BR '\-'
  130. and the implementation treats the
  131. .BR '\-'
  132. as meaning standard input.
  133. Otherwise, the standard input shall not be used.
  134. See the INPUT FILES section.
  135. .SH "INPUT FILES"
  136. If the
  137. .BR \-c
  138. option is specified, the input file can contain arbitrary data;
  139. otherwise, the input file shall be a text file.
  140. .SH "ENVIRONMENT VARIABLES"
  141. The following environment variables shall affect the execution of
  142. .IR tail :
  143. .IP "\fILANG\fP" 10
  144. Provide a default value for the internationalization variables that are
  145. unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
  146. .IR "Section 8.2" ", " "Internationalization Variables"
  147. for the precedence of internationalization variables used to determine
  148. the values of locale categories.)
  149. .IP "\fILC_ALL\fP" 10
  150. If set to a non-empty string value, override the values of all the
  151. other internationalization variables.
  152. .IP "\fILC_CTYPE\fP" 10
  153. Determine the locale for the interpretation of sequences of bytes of
  154. text data as characters (for example, single-byte as opposed to
  155. multi-byte characters in arguments and input files).
  156. .IP "\fILC_MESSAGES\fP" 10
  157. .br
  158. Determine the locale that should be used to affect the format and
  159. contents of diagnostic messages written to standard error.
  160. .IP "\fINLSPATH\fP" 10
  161. Determine the location of message catalogs for the processing of
  162. .IR LC_MESSAGES .
  163. .SH "ASYNCHRONOUS EVENTS"
  164. Default.
  165. .SH STDOUT
  166. The designated portion of the input file shall be written to standard
  167. output.
  168. .SH STDERR
  169. The standard error shall be used only for diagnostic messages.
  170. .SH "OUTPUT FILES"
  171. None.
  172. .SH "EXTENDED DESCRIPTION"
  173. None.
  174. .SH "EXIT STATUS"
  175. The following exit values shall be returned:
  176. .IP "\00" 6
  177. Successful completion.
  178. .IP >0 6
  179. An error occurred.
  180. .SH "CONSEQUENCES OF ERRORS"
  181. Default.
  182. .LP
  183. .IR "The following sections are informative."
  184. .SH "APPLICATION USAGE"
  185. The
  186. .BR \-c
  187. option should be used with caution when the input is a text file
  188. containing multi-byte characters; it may produce output that does not
  189. start on a character boundary.
  190. .P
  191. Although the input file to
  192. .IR tail
  193. can be any type, the results might not be what would be expected on
  194. some character special device files or on file types not described by
  195. the System Interfaces volume of POSIX.1\(hy2017. Since this volume of POSIX.1\(hy2017 does not specify the block size used when doing
  196. input,
  197. .IR tail
  198. need not read all of the data from devices that only perform block
  199. transfers.
  200. .P
  201. When using
  202. .IR tail
  203. to process pathnames, and the
  204. .BR \-c
  205. option is not specified, it is recommended that LC_ALL, or at least
  206. LC_CTYPE and LC_COLLATE, are set to POSIX or C in the environment,
  207. since pathnames can contain byte sequences that do not form valid
  208. characters in some locales, in which case the utility's behavior
  209. would be undefined. In the POSIX locale each byte is a valid
  210. single-byte character, and therefore this problem is avoided.
  211. .SH EXAMPLES
  212. The
  213. .BR \-f
  214. option can be used to monitor the growth of a file that is being
  215. written by some other process. For example, the command:
  216. .sp
  217. .RS 4
  218. .nf
  219. tail -f fred
  220. .fi
  221. .P
  222. .RE
  223. .P
  224. prints the last ten lines of the file
  225. .BR fred ,
  226. followed by any lines that are appended to
  227. .BR fred
  228. between the time
  229. .IR tail
  230. is initiated and killed. As another example, the command:
  231. .sp
  232. .RS 4
  233. .nf
  234. tail -f -c 15 fred
  235. .fi
  236. .P
  237. .RE
  238. .P
  239. prints the last 15 bytes of the file
  240. .BR fred ,
  241. followed by any bytes that are appended to
  242. .BR fred
  243. between the time
  244. .IR tail
  245. is initiated and killed.
  246. .SH RATIONALE
  247. This version of
  248. .IR tail
  249. was created to allow conformance to the Utility Syntax Guidelines. The
  250. historical
  251. .BR \-b
  252. option was omitted because of the general non-portability of block-sized
  253. units of text. The
  254. .BR \-c
  255. option historically meant ``characters'', but this volume of POSIX.1\(hy2017 indicates
  256. that it means ``bytes''. This was selected to allow reasonable
  257. implementations when multi-byte characters are possible; it was not
  258. named
  259. .BR \-b
  260. to avoid confusion with the historical
  261. .BR \-b .
  262. .P
  263. The origin of counting both lines and bytes is 1, matching all
  264. widespread historical implementations. Hence
  265. .IR tail
  266. .BR \-n
  267. +0 is not conforming usage because it attempts to output line zero; but
  268. note that
  269. .IR tail
  270. .BR \-n
  271. 0 does conform, and outputs nothing.
  272. .P
  273. Earlier versions of this standard allowed the following forms in the
  274. SYNOPSIS:
  275. .sp
  276. .RS 4
  277. .nf
  278. tail -\fB[\fRnumber\fB][\fRb|c|l\fB][\fRf\fB] [\fIfile\fB]\fR
  279. tail \(pl\fB[\fRnumber\fB][\fRb|c|l\fB][\fRf\fB] [\fIfile\fB]\fR
  280. .fi
  281. .P
  282. .RE
  283. .P
  284. These forms are no longer specified by POSIX.1\(hy2008, but may be
  285. present in some implementations.
  286. .P
  287. The restriction on the internal buffer is a compromise between the
  288. historical System V implementation of 4\|096 bytes and the BSD 32\|768
  289. bytes.
  290. .P
  291. The
  292. .BR \-f
  293. option has been implemented as a loop that sleeps for 1 second and
  294. copies any bytes that are available. This is sufficient, but if more
  295. efficient methods of determining when new data are available are
  296. developed, implementations are encouraged to use them.
  297. .P
  298. Historical documentation indicates that
  299. .IR tail
  300. ignores the
  301. .BR \-f
  302. option if the input file is a pipe (pipe and FIFO on systems that
  303. support FIFOs). On BSD-based systems, this has been true; on System
  304. V-based systems, this was true when input was taken from standard
  305. input, but it did not ignore the
  306. .BR \-f
  307. flag if a FIFO was named as the
  308. .IR file
  309. operand. Since the
  310. .BR \-f
  311. option is not useful on pipes and all historical implementations ignore
  312. .BR \-f
  313. if no
  314. .IR file
  315. operand is specified and standard input is a pipe, this volume of POSIX.1\(hy2017 requires this
  316. behavior. However, since the
  317. .BR \-f
  318. option is useful on a FIFO, this volume of POSIX.1\(hy2017 also requires that
  319. if a FIFO is named, the
  320. .BR \-f
  321. option shall not be ignored. Earlier versions of this standard did
  322. not state any requirement for the case where no
  323. .IR file
  324. operand is specified and standard input is a FIFO. The standard has
  325. been updated to reflect current practice which is to treat this case
  326. the same as a pipe on standard input.
  327. Although historical behavior does not ignore the
  328. .BR \-f
  329. option for other file types, this is unspecified so that
  330. implementations are allowed to ignore the
  331. .BR \-f
  332. option if it is known that the file cannot be extended.
  333. .SH "FUTURE DIRECTIONS"
  334. None.
  335. .SH "SEE ALSO"
  336. .IR "\fIhead\fR\^"
  337. .P
  338. The Base Definitions volume of POSIX.1\(hy2017,
  339. .IR "Chapter 8" ", " "Environment Variables",
  340. .IR "Section 12.2" ", " "Utility Syntax Guidelines"
  341. .\"
  342. .SH COPYRIGHT
  343. Portions of this text are reprinted and reproduced in electronic form
  344. from IEEE Std 1003.1-2017, Standard for Information Technology
  345. -- Portable Operating System Interface (POSIX), The Open Group Base
  346. Specifications Issue 7, 2018 Edition,
  347. Copyright (C) 2018 by the Institute of
  348. Electrical and Electronics Engineers, Inc and The Open Group.
  349. In the event of any discrepancy between this version and the original IEEE and
  350. The Open Group Standard, the original IEEE and The Open Group Standard
  351. is the referee document. The original Standard can be obtained online at
  352. http://www.opengroup.org/unix/online.html .
  353. .PP
  354. Any typographical or formatting errors that appear
  355. in this page are most likely
  356. to have been introduced during the conversion of the source files to
  357. man page format. To report such errors, see
  358. https://www.kernel.org/doc/man-pages/reporting_bugs.html .