NAME
tail — copy the
last part of a file
SYNOPSIS
tail |
[-f][-c number| -n number]
[file] |
tail |
-[number][b|c|l][f] [file] |
tail |
+[number][b|c|l][f] [file] |
DESCRIPTION
The tail utility copies its input file to
the standard output beginning at a designated place.
Copying begins at the point in the file indicated by the
-c number or
-n number options (or the ±
number portion of the argument to the obsolescent
version). The option-argument number is counted in units
of lines or bytes, according to the options -n and
-c (or, in the obsolescent version, the appended
option suffixes l (lines), b (512-byte blocks) or c (bytes)). Both line and
byte counts start from 1.
Tails relative to the end of the file may be saved in an internal buffer, and thus may be limited in length. Such a buffer, if any, will be no smaller than {LINE_MAX}*10 bytes.
OPTIONS
The tail utility supports the XBD
specification,
Utility
Syntax Guidelines , except that the obsolescent version accepts
multi-character options that can preceded by a plus sign.
The following options are supported:
- -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:
The origin for counting is 1; that is, -c +1 represents the first byte of the file, -c -1 the last.
Sign Copying Starts + Relative to the beginning of the file. - Relative to the end of the file. none Relative to the end of the file.
- -f
- If the input file is a regular file or if the file operand specifies a
FIFO, do not terminate after the last line of the input file has been
copied, but read and copy further bytes from the input file when they
become available. If no file operand is specified and standard input is a
pipe, the
-foption will be ignored. If the input file is not a FIFO, pipe or regular file, it is unspecified whether or not the-foption will be ignored. - -n number
- This option is 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.
In the non-obsolescent form, if neither -c
nor -n is specified, -n 10 is
assumed.
In the obsolescent version, an argument beginning with a
"-" or "+" can be used as a single option. The argument
±number with the letter c specified as a suffix is
equivalent to -c ±number;
±number with the b suffix is equivalent to
-c ±number *512;
±number with the letter l specified as a suffix, or
with none of b, c nor l as a suffix, is equivalent to
-n ±number. If
number is not specified in these forms, 10 will be used.
The letter f specified as a suffix is equivalent to specifying the
-f option. If the
-[
number
]c[f]
form is used and neither number nor the f suffix is
specified, it will be interpreted as the -c 10 option.
OPERANDS
The following operand is supported:
- file
- A pathname of an input file. If no file operands are specified, the standard input will be used.
STDIN
The standard input will be used only if no file operands are specified. See the INPUT FILES section.
INPUT FILES
If the -c option is specified, the input
file can contain arbitrary data; otherwise, the input file must be a text
file.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of
tail :
LANG- Provide a default value for the internationalisation variables that are
unset or null. If
LANGis unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL- If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_CTYPE- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files).
LC_MESSAGES- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
NLSPATH- Determine the location of message catalogues for the processing of LC_MESSAGES .
ASYNCHRONOUS EVENTS
Default.
STDOUT
The designated portion of the input file will be written to standard output.
STDERR
Used only for diagnostic messages.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
None.
EXIT STATUS
The following exit values are returned:
CONSEQUENCES OF ERRORS
Default.
APPLICATION USAGE
The -c option should be used with caution
when the input is a text file containing multi-byte characters; it may
produce output that does not start on a character boundary.
Although the input file to tail
can be any type, the results might not be what would be expected on some
character special device files or on file types not described by the
XSH specification.
Since this specification does not specify the block size used when doing
input, tail need not read all of the data from
devices that only perform block transfers.
The b suffix in the obsolescent version is not portable outside of XSI-conformant systems.
EXAMPLES
The -f option can be used to monitor the
growth of a file that is being written by some other process. For example,
the command:
tail -f fred prints 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: tail -f -c 15
fred prints the last 15 bytes of the file fred,
followed by any bytes that are appended to fred between
the time tail is initiated and killed.
FUTURE DIRECTIONS
None.
SEE ALSO
head(1) .