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

NAME

12       tail - copy the last part of a file
13

SYNOPSIS

15       tail [-f][ -c number| -n number][file]
16

DESCRIPTION

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

OPTIONS

31       The tail utility shall  conform  to  the  Base  Definitions  volume  of
32       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
33
34       The following options shall be supported:
35
36       -c  number
37              The  application shall ensure that the number option-argument is
38              a decimal integer whose sign affects the location in  the  file,
39              measured in bytes, to begin the copying:
40
41                       Sign   Copying Starts
42                       +      Relative to the beginning of the file.
43                       -      Relative to the end of the file.
44                       none   Relative to the end of the file.
45
46       The origin for counting shall be 1; that is, -c +1 represents the first
47       byte of the file, -c -1 the last.
48
49       -f     If the input file is a regular file or if the file operand spec‐
50              ifies  a FIFO, do not terminate after the last line of the input
51              file has been copied, but read and copy further bytes  from  the
52              input  file  when  they  become available. If no file operand is
53              specified and standard input is a pipe, the -f option  shall  be
54              ignored. If the input file is not a FIFO, pipe, or regular file,
55              it is unspecified whether or not the -f option shall be ignored.
56
57       -n  number
58              This option shall be equivalent to -c number, except the  start‐
59              ing  location  in the file shall be measured in lines instead of
60              bytes. The origin for counting shall be 1; that is, -n +1 repre‐
61              sents the first line of the file, -n -1 the last.
62
63
64       If neither -c nor -n is specified, -n 10 shall be assumed.
65

OPERANDS

67       The following operand shall be supported:
68
69       file   A  pathname of an input file. If no file operands are specified,
70              the standard input shall be used.
71
72

STDIN

74       The standard input shall be used only if no file  operands  are  speci‐
75       fied. See the INPUT FILES section.
76

INPUT FILES

78       If  the  -c  option  is specified, the input file can contain arbitrary
79       data; otherwise, the input file shall be a text file.
80

ENVIRONMENT VARIABLES

82       The following environment variables shall affect the execution of tail:
83
84       LANG   Provide a default value for the  internationalization  variables
85              that  are  unset  or  null.  (See the Base Definitions volume of
86              IEEE Std 1003.1-2001, Section  8.2,  Internationalization  Vari‐
87              ables  for the precedence of internationalization variables used
88              to determine the values of locale categories.)
89
90       LC_ALL If set to a non-empty string value, override the values  of  all
91              the other internationalization variables.
92
93       LC_CTYPE
94              Determine  the  locale  for  the  interpretation of sequences of
95              bytes of text data as characters (for  example,  single-byte  as
96              opposed to multi-byte characters in arguments and input files).
97
98       LC_MESSAGES
99              Determine  the  locale  that should be used to affect the format
100              and contents of diagnostic messages written to standard error.
101
102       NLSPATH
103              Determine the location of message catalogs for the processing of
104              LC_MESSAGES .
105
106

ASYNCHRONOUS EVENTS

108       Default.
109

STDOUT

111       The  designated  portion of the input file shall be written to standard
112       output.
113

STDERR

115       The standard error shall be used only for diagnostic messages.
116

OUTPUT FILES

118       None.
119

EXTENDED DESCRIPTION

121       None.
122

EXIT STATUS

124       The following exit values shall be returned:
125
126        0     Successful completion.
127
128       >0     An error occurred.
129
130

CONSEQUENCES OF ERRORS

132       Default.
133
134       The following sections are informative.
135

APPLICATION USAGE

137       The -c option should be used with caution when the input is a text file
138       containing  multi-byte  characters; it may produce output that does not
139       start on a character boundary.
140
141       Although the input file to tail can be any type, the results might  not
142       be  what would be expected on some character special device files or on
143       file  types  not  described  by  the  System   Interfaces   volume   of
144       IEEE Std 1003.1-2001.  Since  this  volume of IEEE Std 1003.1-2001 does
145       not specify the block size used when doing input, tail  need  not  read
146       all of the data from devices that only perform block transfers.
147

EXAMPLES

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

RATIONALE

166       This  version  of  tail was created to allow conformance to the Utility
167       Syntax Guidelines. The historical -b option was omitted because of  the
168       general  non-portability  of  block-sized  units of text. The -c option
169       historically    meant    "characters",    but    this     volume     of
170       IEEE Std 1003.1-2001 indicates that it means "bytes". This was selected
171       to allow reasonable implementations when multi-byte characters are pos‐
172       sible; it was not named -b to avoid confusion with the historical -b.
173
174       The  origin  of  counting both lines and bytes is 1, matching all wide‐
175       spread historical implementations.
176
177       The restriction on the internal buffer is a compromise between the his‐
178       torical System V implementation of 4096 bytes and the BSD 32768 bytes.
179
180       The  -f  option has been implemented as a loop that sleeps for 1 second
181       and copies any bytes that are available. This  is  sufficient,  but  if
182       more  efficient  methods of determining when new data are available are
183       developed, implementations are encouraged to use them.
184
185       Historical documentation indicates that tail ignores the -f  option  if
186       the input file is a pipe (pipe and FIFO on systems that support FIFOs).
187       On BSD-based systems, this has been true; on  System  V-based  systems,
188       this  was true when input was taken from standard input, but it did not
189       ignore the -f flag if a FIFO was named as the file operand.  Since  the
190       -f  option  is  not  useful on pipes and all historical implementations
191       ignore -f if no file operand is specified and standard input is a pipe,
192       this  volume  of  IEEE Std 1003.1-2001 requires this behavior. However,
193       since  the  -f  option  is  useful  on   a   FIFO,   this   volume   of
194       IEEE Std 1003.1-2001  also requires that if standard input is a FIFO or
195       a FIFO is named, the -f option shall not be ignored. Although  histori‐
196       cal  behavior  does not ignore the -f option for other file types, this
197       is unspecified so that implementations are allowed  to  ignore  the  -f
198       option if it is known that the file cannot be extended.
199
200       This  was  changed to the current form based on comments noting that -c
201       was almost never used without specifying a number and that there was no
202       need to specify -l if -n number was given.
203

FUTURE DIRECTIONS

205       None.
206

SEE ALSO

208       head
209
211       Portions  of  this text are reprinted and reproduced in electronic form
212       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
213       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
214       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
215       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
216       event of any discrepancy between this version and the original IEEE and
217       The  Open Group Standard, the original IEEE and The Open Group Standard
218       is the referee document. The original Standard can be  obtained  online
219       at http://www.opengroup.org/unix/online.html .
220
221
222
223IEEE/The Open Group                  2003                             TAIL(1P)
Impressum