[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home |
Legal |
Search ]
Commands Reference, Volume 5
tail Command
Purpose
Writes a file to standard output, beginning at a specified
point.
Syntax
Standard Syntax
tail [ -f ] [ -c Number | -n Number | -m Number | -b Number | -k Number ] [ File ]
To Display Lines in Reverse Order
tail [ -r ] [ -n Number ] [ File ]
Description
The tail command writes the
file specified by the File parameter to standard output
beginning at a specified point. If no file is specified, standard input is
used. The Number variable specifies how many units
to write to standard output. The value for the Number
variable can be a positive or negative integer. If the value is preceded by + (plus sign), the file is written to standard output
starting at the specified number of units from the beginning of the file.
If the value is preceded by - (minus sign), the
file is written to standard output starting at the specified number of units
from the end of the file. If the value is not preceded by + (plus sign) or - (minus sign), the file
is read starting at the specified number of units from the end of the file.
The type of unit used by the Number variable to determine the starting point for the count is determined
by the -b, -c, -k, -m, or -n flag. If one
of these flags is not specified, the tail command reads
the last ten lines of the specified file and writes them to standard output.
This is the same as entering -n 10 at the command line.
The -m flag provides consistent
results in both single- and double-byte character environments. The -c flag should be used with caution when the input is a text file containing
multibyte characters, because output can be produced that does not start on
a character boundary.
Flags
-b Number |
Reads the specified file beginning at the 512-byte block location
indicated by the Number variable. |
-c Number |
Reads the specified file beginning at the byte location indicated
by the Number variable. |
-f |
If the input file is a regular file or if the File parameter specifies a FIFO (first-in-first-out), the tail command does not terminate after the last specified unit of the
input file has been copied, but continues to read and copy additional units
from the input file as they become available. If no File parameter is specified and standard input is a pipe, the -f flag is ignored. The tail -f command can be
used to monitor the growth of a file being written by another process. |
-k Number |
Reads the specified file beginning at the 1KB block location indicated
by the Number variable. |
-m Number |
Reads the specified file beginning at the multibyte character location
indicated by the Number variable. Using this flag
provides consistent results in both single- and double-byte character-code-set
environments. |
-n Number |
Reads the specified file beginning at the line location indicated
by the Number variable. |
-r |
Displays the output from the end of the file in reverse order. The
default for the -r flag prints the entire file in reverse
order. If the file is larger than 20,480 bytes, the -r
flag displays only the last 20,480 bytes.
The -r flag is valid only with the -n flag. Otherwise,
it is ignored. |
Exit Status
This command returns the following exit values:
0 |
Successful completion. |
>0 |
An error occurred. |
Examples
- To display the last 10 lines of the notes file, enter:
tail notes
- To specify the number of lines to start reading
from the end of the notes file, enter:
tail -n 20 notes
- To display the notes
file a page at a time, beginning with the 200th byte, enter:
tail -c +200 notes | pg
- To follow the growth of a file, enter:
tail -f accounts
This displays the last 10 lines of the accounts file. The tail command
continues to display lines as they are added to the accounts file. The display continues until you press the Ctrl-C key sequence
to stop it.
File
/usr/bin/tail |
Contains the tail command. |
Related Information
The dd
command, head command, more command, pg command.
Files Overview in AIX 5L Version 5.2 System User's Guide: Operating System and Devices describes
files, file types, and how to name files.
Input and Output Redirection
Overview in AIX 5L Version 5.2 System User's Guide: Operating System and Devices describes how the operating system processes
input and output.
[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home |
Legal |
Search ]