[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    tail(1) manual page Table of Contents

Name

tail - deliver the last part of a file

Synopsis

/usr/bin/tail [ ± 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 ]

Availability

/usr/bin/tail

SUNWcsu

/usr/xpg4/bin/tail

SUNWxcu4

Description

The tail command 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 -c number, -n number, 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.

The r and f options are mutually exclusive. If both are specified on the command line, the f option will be ignored.

Options

The following options are supported:
-b
Units of blocks.

/usr/xpg4/bin/tail

-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.
-c
Units of bytes.
-f
Follow. If the input-file is not a pipe, the program will not terminate after the line of the input-file has been copied, but will enter an endless loop, wherein it sleeps for a second and then attempts to read and copy further records from the input-file. Thus it may be used to monitor the growth of a file that is being written by some other process.
-l
Units of lines.

/usr/xpg4/bin/tail

-n number
Equivalent to -c number, 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.
-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.

Operands

The following operand is supported:
file
A path name of an input file. If no file operands are specified, the standard input will be used.

Examples

For example, the command:

example% tail -f fred

will print the last ten lines of the file fred, followed by any lines that are appended to fred between the time tail is initiated and killed. As another example, the command:

example% tail -15cf fred

will print 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.

Environment

See environ(5) for descriptions of the following environment variables that affect the execution of tail: LC_CTYPE , LC_MESSAGES , and NLSPATH .

Exit Status

The following exit values are returned:
  1. Successful completion.
    >0
    An error occurred.

    See Also

    cat(1) , head(1) , more(1) , pg(1) , dd(1M) , environ(5)

    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 may happen with character special files.


    Table of Contents