tail(1) tail(1)
NAME
tail - deliver the last part of a file
SYNOPSIS
tail [-f] {-c number | -n number} [--] [file] Format 1
tail [place[bcl[rf]]] [file] Format 2
DESCRIPTION
tail prints the contents of the specified file on standard output
beginning at a designated place. If no file name is specified, tail
outputs the contents of standard input.
Tails relative to the end of the file are saved in an internal buffer,
and thus are limited in length. Such a buffer is no smaller than
LINEMAX*10 bytes [see limits(4)].
Various kinds of anomalous behavior may occur if tail is used on char-
acter special files.
OPTIONS
Format 1: New synopsis for tail
-c number
Designates the place in the input file, in bytes, where output is
to begin. number can be specified signed or unsigned:
+ Counting starts at the beginning of the file.
- Counting starts at the end of the file.
Unsigned
Counting starts at the end of the file.
-c must not be combined with -n.
Neither -c nor -n specified: The last 10 lines of file are output
(corresponds to -n 10).
-f (f - follow) If the input file is a file or a FIFO file, the pro-
gram will not terminate after the last line of output has been
displayed, but will enter an endless loop, wherein it sleeps for
at least a second and then attempts to read and copy further
records from the input file. You could use this option to monitor
the growth of a file that is being written by another process. If
the input file is a pipe, -f is ignored.
-n number
Designates the place in the input file, in lines, where output is
to begin. number can be specified signed or unsigned (see -c).
-n cannot be combined with -c.
Page 1 Reliant UNIX 5.44 Printed 11/98
tail(1) tail(1)
Neither -n nor -c specified:
The last 10 lines of file are output (corresponds to -n 10).
-n number corresponds to the old option -number if number is
unsigned or negative (with minus sign), and corresponds to the
old option +number if number is positive (with plus sign).
-- End of the list of options. Must be specified if file begins with
-.
file Name of the input file to be output by tail.
file not specified: tail reads from the standard input.
Format 2: Old synopsis for tail
place
place defines the position in the input file at which display is
to begin. This location may be given as:
+[number]
-[number]
number can be specified as any decimal integer value.
+[number] is calculated relative to the beginning of the
file; -[number] is calculated relative to the end of the
file.
number not specified:
The default value of 10 is assumed.
place not specified:
The default value for place is -10, i.e. 10 lines from the
end of the file.
b Starts display at the block defined by place. A block is a 512-
byte unit.
c Starts display at the character defined by place. (Corresponds to
the -c option in the new synopsis.)
l Starts display at the line defined by place. (Corresponds to the
-n option in the new synopsis.)
Only one of the options b, c, or l may be used at a time. If you omit
all three options, the l option is set by default.
Page 2 Reliant UNIX 5.44 Printed 11/98
tail(1) tail(1)
f (follow) If the input file is a file or a FIFO file, the program
will not terminate after the last line of the input file has been
displayed, but will enter an endless loop, wherein it sleeps for
at least a second and then attempts to read and copy further
records from the input file. You could thus use this option to
monitor the growth of a file that is being written by some other
process. If the input file is a pipe, f is ignored. (Corresponds
to the -f option in the new synopsis.)
r (reverse) Lines are copied from the specified starting point in
the file in reverse order. The default is to output the entire
file in reverse order.
If ther option is used together with a numeric value [number],
the numeric value must be negative. Thus in this case [number]
must not be combined with +.
You must not combine the f and r options.
file Name of the input file to be displayed by tail.
file not specified: tail reads from standard input.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed. If LCMESSAGES is undefined or is defined
as the null string, it defaults to the value of LANG. If LANG is like-
wise undefined or null, the system acts as if it were not internation-
alized.
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization.
EXAMPLES
Example 1
The file months contains the name of a month in each line. The follow-
ing two calls to tail:
$ tail -n 5 months
$ tail -n +8 months
will result in the same output:
August
September
October
November
December
Page 3 Reliant UNIX 5.44 Printed 11/98
tail(1) tail(1)
Example 2
To observe the effect of the -f option, create a shell script that
writes data to a file in an endless loop and run this script in the
background.
The shell script neverend with the following contents would serve the
purpose:
while true
do {
date >>anne
sleep 5
}
done
You can now run this script in the background and then call tail with
option -f and the file anne as its argument:
$ neverend &
656
$ tail -f -n 5 anne
These five
lines
were already
in the file
before any additions.
FRI MAR 22 11:40:35 MET 1991
FRI MAR 22 11:40:40 MET 1991
.
.
.
tail first displays the last five lines of the file anne, followed by
the data written to this file by the script neverend. The process gen-
erated with tail -f can be terminated by pressing the CTRL-C key.
SEE ALSO
cat(1), head(1), more(1), pg(1), limits(4).
Page 4 Reliant UNIX 5.44 Printed 11/98