tail

display last lines of a file 

Command


SYNOPSIS

tail [-f] [-b|-c|-k|-l|-m|-n [±]num] [-U[[[c][lb8oa]][p[lb8oa]]]] [file]

tail

+[num][[b|c|k|l|m|n[f] [-U[[[c][lb8oa]][p[lb8oa]]]] [file]

tail -[num][[b|c|k|l|m|n[f] [-U[[[c][lb8oa]][p[lb8oa]]]] [file]


DESCRIPTION

Calling tail without options displays the last 10 lines of file. This is useful for seeing the most recent entries in log files or any file where new information is appended.

Besides normal ASCII text files, tail also works on UTF-8 files and 16-bit wide Unicode files. Such files normally begin with a multiple-byte marker indicating whether the file's contents are Unicode big-endian, Unicode little-endian, or UTF-8. Such files are detected automatically by tail; however, when the multiple-byte marker is missing you can use the -U option or the TK_STDIO_DEFAULT_INPUT_FORMAT/TK_STDIO_DEFAULT_OUTPUT_FORMAT environment variables to force any file to be treated as a Unicode or UTF-8 file.

Normally, tail's output format defaults to the format of the first file it displays unless the -U option or the TK_STDIO_DEFAULT_OUTPUT_FORMAT environment variable is used to override the output format. For more details on this and other Unicode-related file handling issues see the unicode reference page.

Options

All tail options except -f are mutually exclusive. You can only specify one of them.

-b [±]num 
±[num]b 

begins displaying the file at a location determined by num. If num is preceded by a minus sign (-)or no sign at all, tail displays the last num blocks of the file. If num is preceded by a plus sign (+), tail displays the file beginning with the numth block. For these purposes, a block is 512 characters. As a result, -b num is equivalent to -c num x 512.

If num is not specified, tail behaves as if num was 10.

-c [±]num 
±[num]c 

is similar to the b option, but num is in characters rather than blocks.

-f 
f 

monitors a file as it grows. Every two seconds, tail wakes up and displays any new data at the end of the file. This flag is ignored if reading from the standard input and standard input is a pipe.

-k [±]num 
±[num]k 

is similar to the b option, but num is groups of 1024 characters rather than blocks. Thus, -k num is equivalent to -c num x 1024. For files with single byte characters, this is equivalent to num kilobytes.

-l [±]num 
±[num]l 

is similar to the b option, but num is in lines rather than blocks.

-m [±]num 
±[num]m 

is similar to the b option, but num is in groups of 1048576 characters (1024 x 1024 characters) rather than blocks. Thus, -m num is equivalent to -c num x 1024 x 1024. For files with single byte characters, this is equivalent to num megabytes.

-n [±]num 
±[num]n 

is similar to the b option, but num is in lines rather than blocks.

-U[[[c][lb8oa]][p[lb8oa]]] 

specifies the input format of any file missing the initial multiple-byte marker, the output format produced, or both.

When c is specified, the specifiers that follow it apply to the input consumed.

When p is specified, the specifiers that follow it apply to the output produced.

When neither c nor p are specified, the remaining -U specifiers apply to the input consumed.

When both c and p are specified, the remaining -U arguments apply to both input and output.

The remaining specifiers indicate the format of the characters read from input or written to output (as determined by c and p):

l     little-endian 16-bit wide characters
b     big-endian 16-bit wide characters
8     UTF-8 characters
a     ASCII characters from the ANSI code page
o     ASCII characters from the OEM code page

When multiple format specifiers can be associated with either c or p, the last appropriate one given on the command for each of c and p is used. For example:

-Ucoapl8

is the same as:

-Ucap8

When a p specifier is given without a c specifier and format specifiers are given before the p specifier, those format specifiers apply to the input. For example:

-Uopl

is the same as:

-Ucopl

When c or p is specified with no format specifies, little endian 16-bit wide characters are used by default for either input or output, as appropriate.

As an alternative to specifying formats for both input and output with the same -U option, you can specify the -U option multiple times. For example, the following are identical:

-Uca -Upb
-Ucapb

Note:

The -U specifiers are actually case-insensitive. For example, the following are all identical in their behavior:

-Ucl
-UcL
-UCl
-UCL

-num 

displays the last num lines of the file.

+num 

displays the file beginning with its numth line.


EXAMPLES

These five commands all display the last 10 characters of a file:

tail -c10 filename
tail -c -10 filename
tail -10c filename
tail -c filename

These three commands all display a file beginning with its 10th character:

tail -c +10 filename
tail +10c filename
tail +c filename

ENVIRONMENT VARIABLES

TK_STDIO_DEFAULT_INPUT_FORMAT 

Sets the default input format for files that don't have the initial multibyte marker. The value must be one of those listed in the File Character Formats section of the unicode reference page.

TK_STDIO_DEFAULT_OUTPUT_FORMAT 

Sets the default output format. Normally the format of the first file read is used as the default output format. The value must be one of those listed in the File Character Formats section of the unicode reference page.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Failure due to any of the following:

— insufficient memory
— write error on the standard output
— badly formed line or byte count
— missing number after an option
— error re-opening a file descriptor
2 

Failure due to an unknown command line option.

Messages

Badly formed line/byte count "string

In an option of the form -n num or -num, the num was not a valid number.

Re-opening file descriptor "num

-f was used to follow a file as it grows. tail closed the file associated with the given file descriptor num then tried to open it two seconds later. At this point, tail found it could not re-open the file for reading and, therefore, could not follow the file any longer.


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 7. Windows Server 2008 R2. Windows 8. Windows Server 2012. Windows 10. Windows Server 2016.

The POSIX standard considers all but the first SYNOPSIS line to be obsolescent and does not include the use of b, k, l, or m as either options or suffixes.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
cat, head, more, pg


PTC MKS Toolkit 10.1 Documentation Build 15.