User Commands tail(1) NAME tail - deliver the last part of a file SYNOPSIS /usr/bin/tail /usr/bin/tail [ options ] [file...] /usr/xpg4/bin/tail /usr/xpg4/bin/tail [ options ] [file...] ksh93 tail [ options ] [file...] DESCRIPTION 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. Note that -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. 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. -n, --lines=lines Copy lines lines from each file. A negative value for lines indicates an offset from the end of the file. The default value is 10. -b, --blocks Copy units of 512 bytes (Obsolete). -c, --bytes[=chars] Copy chars bytes from each file. A negative value for chars indicates an offset from the end of the file. The option value may be omitted. -f, --forever|follow Loop forever trying to read more characters as the end of each file to copy new data. Ignored if reading from a pipe or fifo. -h, --headers Output filename headers. On by default; -h means --noheaders. -l, --lines Copy units of lines. This is the default. -L, --log When a --forever file times out via --timeout, verify that the curent 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, --quiet Don't output filename headers. For GNU compatibility. -r, --reverse Output lines in reverse order. -s, --silent Don't warn about timeout expiration and log file changes. -t, --timeout=timeout Stop checking after timeout elapses with no additional --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 -v, --verbose Always ouput filename headers. --man, --html, --nroff Prints builtin manual page in either plain text, HTML or nroff format. --help Prints basic help information --version Prints version information If no options are specified, tail will act as if -n 10 had been specified. 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 attri- butes: /usr/bin/tail ____________________________________________________________ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |_____________________________|_____________________________| | Availability | SUNWcsu | |_____________________________|_____________________________| | CSI | Enabled | |_____________________________|_____________________________| | Interface Stability | See below | |_____________________________|_____________________________| /usr/xpg4/bin/tail ____________________________________________________________ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |_____________________________|_____________________________| | Availability | SUNWxcu4 | |_____________________________|_____________________________| | CSI | Enabled | |_____________________________|_____________________________| | Interface Stability | See below | |_____________________________|_____________________________| The interface stabilty of /usr/bin/tail and /usr/xpg4/bin/tail is Committed except for the command-line options -q/--quiet which are Uncommited and options -b/--blocks which are Commited Obsolete. This command conforms to IEEE Std 1003.1-2008. SEE ALSO cat(1), head(1), ksh93(1), more(1), pg(1), tee(1), dd(1M), attributes(5), environ(5), largefile(5), standards(5), http://www.opengroup.org/onlinepubs/9699919799/utilities/tail.html 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.10 Last change: 13 Jul 2005 4