tail(1) User Commands tail(1)NAMEtail - deliver the last part of a file
SYNOPSIS
/usr/bin/tail and /usr/xpg4/bin/tail
/usr/bin/tail [±s number [lbcr]] [file]
/usr/bin/tail [-lbcr] [file]
/usr/bin/tail [± number [lbcf]] [file]
/usr/bin/tail [-lbcf] [file]
/usr/xpg4/bin/tail [-f | -r] [-c number | -n number] [file]
/usr/xpg4/bin/tail [± number [l | b | c] [f]] [file]
/usr/xpg4/bin/tail [± number [l] [f | r]] [file]
ksh93
tail [options]] [file ...]
DESCRIPTION
/usr/bin/tail and /usr/xpg4/bin/tail
The tail utility copies the named file to the standard output beginning
at a designated place. If no file is named, the standard input is used.
Copying begins at a point in the file indicated by the -cnumber, -nnum‐
ber, or ±number options (if +number is specified, begins at distance
number from the beginning; if -number is specified, from the end of the
input; if number is NULL, the value 10 is assumed). number is counted
in units of lines or byte according to the -c or -n options, or lines,
blocks, or bytes, according to the appended option l, b, or c. When no
units are specified, counting is by lines.
ksh93
tail copies one or more input files to standard output starting at a
designated point for each file. Copying starts at the point indicated
by the options and is unlimited in size.
By default a header of the form ==> filename <== is output before all
but the first file but this can be changed with the -q and -v options.
If no file is given, or if the file is -, tail copies from standard
input. The start of the file is defined as the current offset.
The option argument for -c can optionally be followed by one of the
following characters to specify a different unit other than a single
byte:
b 512 bytes
k 1-kilobyte
m 1-megabyte
-c counts in bytes and not in characters (which affects texts using
multi-byte characters).
For backwards compatibility, -number is equivalent to -n number and
+number is equivalent to -n -number.
The -b option is obsolete because of the general non-portability of
block-sized units of text.
This command conforms to IEEE Std 1003.1-2008.
OPTIONS
/usr/bin/tail and /usr/xpg4/bin/tail
The following options are supported for both /usr/bin/tail and
/usr/xpg4/bin/tail. The -r and -f options are mutually exclusive. If
both are specified on the command line, the -f option is ignored.
-b Units of blocks.
-c Units of bytes.
-f Follow. If the input-file is not a pipe, the program does not
terminate after the line of the input-file has been copied, but
enters an endless loop, wherein it sleeps for a second and then
attempts to read and copy further records from the input-file.
Thus it can be used to monitor the growth of a file that is being
written by some other process.
-l Units of lines.
-r Reverse. Copies lines from the specified starting point in the
file in reverse order. The default for r is to print the entire
file in reverse order.
/usr/xpg4/bin/tail
The following options are supported for /usr/xpg4/bin/tail only:
-c number The number option-argument must be a decimal integer whose
sign affects the location in the file, measured in bytes,
to begin the copying:
+ Copying starts relative to the beginning of the
file.
− Copying starts relative to the end of the file.
none Copying starts relative to the end of the file.
The origin for counting is 1; that is, -c+1 represents the
first byte of the file, -c−1 the last.
-n number Equivalent to -cnumber, except the starting location in
the file is measured in lines instead of bytes. The origin
for counting is 1. That is, -n+1 represents the first line
of the file, -n−1 the last.
ksh93
The following options are supported for the ksh93 built-in version of
tail. The -r and -f options are mutually exclusive. If both are speci‐
fied on the command line, the -f option is ignored.
-n Copy lines from each file. A negative value for
--lines=lines lines indicates an offset from the end of the
file. The default value is 10.
-b Copy units of 512 bytes (Obsolete).
--blocks
-c Copy chars bytes from each file. A negative value
--bytes[=chars] for chars indicates an offset from the end of the
file. The option value may be omitted.
-f Loop forever trying to read more characters as the
--forever|follow end of each file to copy new data. Ignored if
reading from a pipe or fifo.
-h Output filename headers. On by default. -h means
--headers--noheaders.
-l Copy units of lines. This is the default.
--lines
-L When a --forever file times out via --timeout,
--log verify that the current file has not been renamed
and replaced by another file of the same name (a
common log file practice) before giving up on the
file.
-q Don't output filename headers. For GNU compatibil‐
--quiet ity.
-r Output lines in reverse order.
--reverse
-s Don't warn about timeout expiration and log file
--silent changes.
-t Stop checking after timeout elapses with no addi‐
--timeout=timeout tional --forever output. A separate elapsed time
is maintained for each file operand. There is no
timeout by default. The default timeout unit is
seconds. timeout may be a catenation of 1 or more
integers, each followed by a 1 character suffix.
The suffix may be omitted from the last integer,
in which case it is interpreted as seconds. The
supported suffixes are:
s seconds
m minutes
h hours
d days
w weeks
M months
y years
S scores
--help Prints basic help information.
--man Prints built-in manual page in either plain text,
--html HTML or nroff format.
--nroff
--version Prints version information.
OPERANDS
The following operand is supported:
file A path name of an input file. If no file operands are speci‐
fied, the standard input is used.
USAGE
See largefile(5) for the description of the behavior of tail when
encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
EXAMPLES
Example 1 Using the tail Command
The following command prints the last ten lines of the file fred, fol‐
lowed by any lines that are appended to fred between the time tail is
initiated and killed.
example% tail-f fred
The next command prints the last 15 bytes of the file fred, followed by
any lines that are appended to fred between the time tail is initiated
and killed:
example% tail-15cf fred
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables
that affect the execution of tail: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
/usr/bin/tail
┌─────────────────────────────┬─────────────────────────────┐
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
├─────────────────────────────┼─────────────────────────────┤
│Availability │SUNWcs │
├─────────────────────────────┼─────────────────────────────┤
│CSI │Enabled │
└─────────────────────────────┴─────────────────────────────┘
/usr/xpg4/bin/tail
┌─────────────────────────────┬─────────────────────────────┐
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
├─────────────────────────────┼─────────────────────────────┤
│Availability │SUNWxcu4 │
├─────────────────────────────┼─────────────────────────────┤
│CSI │Enabled │
├─────────────────────────────┼─────────────────────────────┤
│Interface Stability │Committed │
├─────────────────────────────┼─────────────────────────────┤
│Standard │See standards(5). │
└─────────────────────────────┴─────────────────────────────┘
ksh93
┌─────────────────────────────┬─────────────────────────────┐
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
├─────────────────────────────┼─────────────────────────────┤
│Availability │SUNWcsu │
├─────────────────────────────┼─────────────────────────────┤
│CSI │Enabled │
├─────────────────────────────┼─────────────────────────────┤
│Interface Stability │See below. │
└─────────────────────────────┴─────────────────────────────┘
The Interface Stability of the ksh93 built-in command tail is Committed
except for the command-line options -q/--quiet which are Uncommited and
options -b/--blockswhich are (Obsolete).
SEE ALSOcat(1), head(1), more(1), pg(1), dd(1M), attributes(5), environ(5),
largefile(5), standards(5)
IEEE Std 1003.1-2008
NOTES
Piped tails relative to the end of the file are stored in a buffer, and
thus are limited in length. Various kinds of anomalous behavior can
happen with character special files.
SunOS 5.11 29 Nov 2009 tail(1)