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

NAME

6       tail - copy the last part of a file
7

SYNOPSIS

9       tail [-f][ -c number| -n number][file]
10

DESCRIPTION

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

OPTIONS

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

OPERANDS

61       The following operand shall be supported:
62
63       file   A pathname of an input file. If no file operands are  specified,
64              the standard input shall be used.
65
66

STDIN

68       The  standard  input  shall be used only if no file operands are speci‐
69       fied. See the INPUT FILES section.
70

INPUT FILES

72       If the -c option is specified, the input  file  can  contain  arbitrary
73       data; otherwise, the input file shall be a text file.
74

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

102       Default.
103

STDOUT

105       The designated portion of the input file shall be written  to  standard
106       output.
107

STDERR

109       The standard error shall be used only for diagnostic messages.
110

OUTPUT FILES

112       None.
113

EXTENDED DESCRIPTION

115       None.
116

EXIT STATUS

118       The following exit values shall be returned:
119
120        0     Successful completion.
121
122       >0     An error occurred.
123
124

CONSEQUENCES OF ERRORS

126       Default.
127
128       The following sections are informative.
129

APPLICATION USAGE

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

EXAMPLES

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

RATIONALE

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

FUTURE DIRECTIONS

199       None.
200

SEE ALSO

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