tail

display last lines of a file

Command


SYNOPSIS

tail [-f] [-b|-c|-k|-l|-m|-n [±]num] [file]

tail

+[num][[b|c|k|l|m|n[f] [file]

tail -[num][[b|c|k|l|m|n[f] [file]


DESCRIPTION

Calling tail without options displays the last 10 lines of file. This is useful for seeing the most recent entries in log files or any file where new information is appended.

Options

All tail options except -f are mutually exclusive. You can only specify one of them.
-b [±]num
±[num]b

begins displaying the file at a location determined by num. If num is preceded by a minus sign (-)or no sign at all, tail displays the last num blocks of the file. If num is preceded by a plus sign (+), tail displays the file beginning with the numth block. A block is 512 bytes. As a result, -b num is equivalent to -c num x 512.

If num is not specified, tail behaves as if num was 10.

-c [±]num
±[num]c

is similar to the b option, but num is in bytes rather than blocks.

-f
f

monitors a file as it grows. Every two seconds, tail wakes up and displays any new data at the end of the file. This flag is ignored if reading from the standard input and standard input is a pipe.

-k [±]num
±[num]k

is similar to the b option, but num is in kilobytes (1024 bytes) rather than blocks. Thus, -k num is equivalent to -c num x 1024.

-l [±]num
±[num]l

is similar to the b option, but num is in lines rather than blocks.

-m [±]num
±[num]m

is similar to the b option, but num is in megabytes (1024 x 1024 bytes) rather than blocks. Thus, -m num is equivalent to -c num x 1024 x 1024.

-n [±]num
±[num]n

is similar to the b option, but num is in lines rather than blocks.

-num

displays the last num lines of the file.

+num

displays the file beginning with its numth line.


EXAMPLES

These five commands all display the last 10 bytes of a file:
tail -c10 filename
tail -c -10 filename
tail -10c filename
tail -c filename
These three commands all display a file beginning with its 10th byte:
tail -c +10 filename
tail +10c filename
tail +c filename

DIAGNOSTICS

Possible exit status values are:
0

Successful completion.

1

Failure due to any of the following:

— insufficient memory
— write error on the standard output
— badly formed line or byte count
— missing number after an option
— error re-opening a file descriptor
2

Failure due to an unknown command line option.

Messages

Badly formed line/byte count "string"

In an option of the form -n num or -num, the num was not a valid number.

Re-opening file descriptor "num"

-f was used to follow a file as it grows. tail closed the file associated with the given file descriptor num then tried to open it two seconds later. At this point, tail found it could not re-open the file for reading and, therefore, could not follow the file any longer.


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0.

The POSIX standard considers all but the first SYNOPSIS line to be obsolescent and does not include the use of b, k, l, or m as either options or suffixes.


SEE ALSO

Commands:
cat, head, more


Updated MKS Toolkit [3khat16.ico]HP3000 [3khat16.ico]3kMail [archive16.gif]