1TAIL(1P)                   POSIX Programmer's Manual                  TAIL(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       tail — copy the last part of a file
14

SYNOPSIS

16       tail [−f] [−c number|−n number] [file]
17

DESCRIPTION

19       The tail utility shall copy its  input  file  to  the  standard  output
20       beginning at a designated place.
21
22       Copying shall begin at the point in the file indicated by the −c number
23       or −n number options. The option-argument number shall  be  counted  in
24       units of lines or bytes, according to the options −n and −c.  Both line
25       and byte counts start from 1.
26
27       Tails relative to the end of the file may be saved in an internal  buf‐
28       fer, and thus may be limited in length. Such a buffer, if any, shall be
29       no smaller than {LINE_MAX}*10 bytes.
30

OPTIONS

32       The tail utility shall  conform  to  the  Base  Definitions  volume  of
33       POSIX.1‐2008,  Section 12.2, Utility Syntax Guidelines, except that '+'
34       may be recognized as an option delimiter as well as '−'.
35
36       The following options shall be supported:
37
38       −c number The application shall ensure that the number  option-argument
39                 is  a decimal integer, optionally including a sign.  The sign
40                 shall affect the location in the file, measured in bytes,  to
41                 begin the copying:
42
43                        ┌─────┬────────────────────────────────────────┐
44Sign Copying Starts             
45                        ├─────┼────────────────────────────────────────┤
46                        │ +   │ Relative to the beginning of the file. │
47                        │ −   │ Relative to the end of the file.       │
48none │ Relative to the end of the file.       │
49                        └─────┴────────────────────────────────────────┘
50                 The  application  shall ensure that if the sign of the number
51                 option-argument is '+', the number option-argument is a  non-
52                 zero decimal integer.
53
54                 The origin for counting shall be 1; that is, −c +1 represents
55                 the first byte of the file, −c −1 the last.
56
57       −f        If the input file is a regular file or if  the  file  operand
58                 specifies a FIFO, do not terminate after the last line of the
59                 input file has been copied, but read and copy  further  bytes
60                 from  the  input  file when they become available. If no file
61                 operand is specified and standard input is a  pipe  or  FIFO,
62                 the  −f  option  shall be ignored. If the input file is not a
63                 FIFO, pipe, or regular file, it is unspecified whether or not
64                 the −f option shall be ignored.
65
66       −n number This  option  shall  be  equivalent  to −c number, except the
67                 starting location in the file  shall  be  measured  in  lines
68                 instead  of  bytes.  The origin for counting shall be 1; that
69                 is, −n +1 represents the first line of the file,  −n  −1  the
70                 last.
71
72       If neither −c nor −n is specified, −n 10 shall be assumed.
73

OPERANDS

75       The following operand shall be supported:
76
77       file      A pathname of an input file. If no file operand is specified,
78                 the standard input shall be used.
79

STDIN

81       The standard input shall be used if no file operand is  specified,  and
82       shall  be used if the file operand is '−' and the implementation treats
83       the '−' as meaning standard input.  Otherwise, the standard input shall
84       not be used.  See the INPUT FILES section.
85

INPUT FILES

87       If  the  −c  option  is specified, the input file can contain arbitrary
88       data; otherwise, the input file shall be a text file.
89

ENVIRONMENT VARIABLES

91       The following environment variables shall affect the execution of tail:
92
93       LANG      Provide a default value for  the  internationalization  vari‐
94                 ables  that are unset or null. (See the Base Definitions vol‐
95                 ume of POSIX.1‐2008, Section 8.2, Internationalization  Vari‐
96                 ables  for  the  precedence of internationalization variables
97                 used to determine the values of locale categories.)
98
99       LC_ALL    If set to a non-empty string value, override  the  values  of
100                 all the other internationalization variables.
101
102       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
103                 bytes of text data as characters (for example, single-byte as
104                 opposed  to  multi-byte  characters  in  arguments  and input
105                 files).
106
107       LC_MESSAGES
108                 Determine the locale that should be used to affect the format
109                 and  contents  of  diagnostic  messages  written  to standard
110                 error.
111
112       NLSPATH   Determine the location of message catalogs for the processing
113                 of LC_MESSAGES.
114

ASYNCHRONOUS EVENTS

116       Default.
117

STDOUT

119       The  designated  portion of the input file shall be written to standard
120       output.
121

STDERR

123       The standard error shall be used only for diagnostic messages.
124

OUTPUT FILES

126       None.
127

EXTENDED DESCRIPTION

129       None.
130

EXIT STATUS

132       The following exit values shall be returned:
133
134        0    Successful completion.
135
136       >0    An error occurred.
137

CONSEQUENCES OF ERRORS

139       Default.
140
141       The following sections are informative.
142

APPLICATION USAGE

144       The −c option should be used with caution when the input is a text file
145       containing  multi-byte  characters; it may produce output that does not
146       start on a character boundary.
147
148       Although the input file to tail can be any type, the results might  not
149       be  what would be expected on some character special device files or on
150       file  types  not  described  by  the  System   Interfaces   volume   of
151       POSIX.1‐2008.  Since  this  volume of POSIX.1‐2008 does not specify the
152       block size used when doing input, tail need not read all  of  the  data
153       from devices that only perform block transfers.
154

EXAMPLES

156       The −f option can be used to monitor the growth of a file that is being
157       written by some other process. For example, the command:
158
159           tail −f fred
160
161       prints the last ten lines of the file fred, followed by any lines  that
162       are  appended to fred between the time tail is initiated and killed. As
163       another example, the command:
164
165           tail −f −c 15 fred
166
167       prints the last 15 bytes of the file fred, followed by any  bytes  that
168       are appended to fred between the time tail is initiated and killed.
169

RATIONALE

171       This  version  of  tail was created to allow conformance to the Utility
172       Syntax Guidelines. The historical −b option was omitted because of  the
173       general  non-portability  of  block-sized  units of text. The −c option
174       historically meant ``characters'',  but  this  volume  of  POSIX.1‐2008
175       indicates  that  it means ``bytes''. This was selected to allow reason‐
176       able implementations when multi-byte characters are  possible;  it  was
177       not named −b to avoid confusion with the historical −b.
178
179       The  origin  of  counting both lines and bytes is 1, matching all wide‐
180       spread historical implementations. Hence tail −n +0 is  not  conforming
181       usage  because it attempts to output line zero; but note that tail −n 0
182       does conform, and outputs nothing.
183
184       Earlier versions of this standard allowed the following  forms  in  the
185       SYNOPSIS:
186
187           tail −[number][b|c|l][f] [file]
188           tail +[number][b|c|l][f] [file]
189
190       These forms are no longer specified by POSIX.1‐2008, but may be present
191       in some implementations.
192
193       The restriction on the internal buffer is a compromise between the his‐
194       torical System V implementation of 4096 bytes and the BSD 32768 bytes.
195
196       The  −f  option has been implemented as a loop that sleeps for 1 second
197       and copies any bytes that are available. This  is  sufficient,  but  if
198       more  efficient  methods of determining when new data are available are
199       developed, implementations are encouraged to use them.
200
201       Historical documentation indicates that tail ignores the −f  option  if
202       the input file is a pipe (pipe and FIFO on systems that support FIFOs).
203       On BSD-based systems, this has been true; on  System  V-based  systems,
204       this  was true when input was taken from standard input, but it did not
205       ignore the −f flag if a FIFO was named as the file operand.  Since  the
206       −f  option  is  not  useful on pipes and all historical implementations
207       ignore −f if no file operand is specified and standard input is a pipe,
208       this  volume of POSIX.1‐2008 requires this behavior. However, since the
209       −f option is useful  on  a  FIFO,  this  volume  of  POSIX.1‐2008  also
210       requires  that  if a FIFO is named, the −f option shall not be ignored.
211       Earlier versions of this standard did not state any requirement for the
212       case  where  no file operand is specified and standard input is a FIFO.
213       The standard has been updated to reflect current practice which  is  to
214       treat this case the same as a pipe on standard input.  Although histor‐
215       ical behavior does not ignore the −f option for other file types,  this
216       is  unspecified  so  that  implementations are allowed to ignore the −f
217       option if it is known that the file cannot be extended.
218

FUTURE DIRECTIONS

220       None.
221

SEE ALSO

223       head
224
225       The Base Definitions volume of  POSIX.1‐2008,  Chapter  8,  Environment
226       Variables, Section 12.2, Utility Syntax Guidelines
227
229       Portions  of  this text are reprinted and reproduced in electronic form
230       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
231       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
232       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
233       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
234       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
235       event of any discrepancy between this version and the original IEEE and
236       The Open Group Standard, the original IEEE and The Open Group  Standard
237       is  the  referee document. The original Standard can be obtained online
238       at http://www.unix.org/online.html .
239
240       Any typographical or formatting errors that appear  in  this  page  are
241       most likely to have been introduced during the conversion of the source
242       files to man page format. To report such errors,  see  https://www.ker
243       nel.org/doc/man-pages/reporting_bugs.html .
244
245
246
247IEEE/The Open Group                  2013                             TAIL(1P)
Impressum