DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

tail(1)


tail -- deliver the last part of a file

Synopsis

tail [-f] [-c number | -n number] [file]

tail [+/-number] [c | l | b] [f | r] [file]

Description

tail copies the named file to the standard output beginning at a designated place. If no file is named, the standard input is used.

tail processes supplementary code set characters according to the locale specified in the LC_CTYPE environment variable (see LANG on environ(5)), except that multibyte characters may be split, and so not be displayed correctly, when the -b or -c options are specified.

Options


-c number
If number has no sign, or has a negative sign (-), tail will start copying at the absolute value of number bytes from the end of the file. If number has a + in front of it, copying starts at number bytes from the start of the file. The origin for the value of number is 1. Therefore, -c +1 represents the first byte of the file, and -c -1 the last byte of the file.

-n number
This option is the same as the -c option, except the unit is lines rather than bytes. Therefore, -n will start copying at number lines from the start or end of the file, rather than number bytes. The origin for the value of number is 1. Therefore, -n +1 represents the first line of the file, and -n -1 the last line of the file.

If neither -c nor -n is specified, the option -n 10 will be assumed.


-f
With the -f (follow) option, if the input 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.

+/-[number][c|l|b][f|r]
If +number, copying begins at distance number from the beginning of the input. If -number, copying begins at distance number from the end of the input. If number is null, the value 10 is assumed. number is counted in units of lines, blocks, or bytes, according to the appended option l, b, or c. When no units are specified, counting is by lines.

If number is not null, then:

The f option in this synopsis is identical to the normal -f option.

The r option copies lines from the specified starting point in the file in reverse order. number is the count of lines from the end of the file, regardless of the sign. The default for r is to print the entire file in reverse order.

The r and f options are mutually exclusive.

Examples

The command:

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:

tail -f -c 15 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.

Files


/usr/lib/locale/locale/LC_MESSAGES/uxcore.abi
language-specific message file (see LANG on environ(5)).

References

cat(1), dd(1M), head(1), more(1), pg(1), tail(1)

Notices

The tail command uses a buffer to seek back from the end of a file and this limits the amount of data returned when using commands such as:
   cat file | tail -n 1000 > /tmp/file
   tail -n 1000 file

In addition, the number of lines returned by tail varies depending on the length of the lines in the file; the total amount of data returned is limited to the buffer size used (LINE_MAX*10 bytes, or about 20Kbytes).

The tail command does not work reliably with character special files.

The second synopsis form (+/-[number][c|l|b][f|r]) may be removed in future releases, and so should be avoided.


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004