xref: /illumos-gate/usr/src/man/man1/tail.1 (revision 4c28a617e3922d92a58e813a5b955eb526b9c386)

Sun Microsystems, Inc. gratefully acknowledges The Open Group for
permission to reproduce portions of its copyrighted documentation.
Original documentation from The Open Group can be obtained online at
http://www.opengroup.org/bookstore/.

The Institute of Electrical and Electronics Engineers and The Open
Group, have given us permission to reprint portions of their
documentation.

In the following statement, the phrase ``this text'' refers to portions
of the system documentation.

Portions of this text are reprinted and reproduced in electronic form
in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
Standard for Information Technology -- Portable Operating System
Interface (POSIX), The Open Group Base Specifications Issue 6,
Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
Engineers, Inc and The Open Group. In the event of any discrepancy
between these versions and the original IEEE and The Open Group
Standard, the original IEEE and The Open Group Standard is the referee
document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html.

This notice shall appear on any product containing this material.

The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.

You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.

When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]


Copyright 1989 AT&T
Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
Portions Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved

TAIL 1 "Jul 13, 2005"
NAME
tail - deliver the last part of a file
SYNOPSIS

/usr/bin/tail [\(+-s number [lbcr]] [file]

/usr/bin/tail [-lbcr] [file]

/usr/bin/tail [\(+- number [lbcfF]] [file]

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

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, -nnumber, 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.

OPTIONS

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, tail does not terminate after the last line of the input-file has been copied, but enters an endless loop, wherein it watches the file for modifications and 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. If the watched file is truncated tail will begin reading records from the start of the file.

-F

Follow named file. Operates as with -f, except that if the file is moved (e.g. if a watched log file is rotated) tail will close the original file and begin reading records from the start of the file with the specified name if and when that file is recreated.

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

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.

OPERANDS

The following operand is supported: file

A path name of an input file. If no file operands are specified, 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, followed 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:

ATTRIBUTE TYPE ATTRIBUTE VALUE
CSI Enabled
ATTRIBUTE TYPE ATTRIBUTE VALUE
CSI Enabled
Interface Stability Standard
SEE ALSO

cat(1), head(1), more(1), pg(1), dd(1M), attributes(5), environ(5), largefile(5), standards(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 can happen with character special files.