tail Command Purpose Writes a file to standard output, beginning at a specified point. Syntax Recommended Syntax tail [ -f | -r ] [ -c Number | -n Number | -m Number | -b Number | -k Number ] [ File ] Deprecated Syntax tail [ + | - ] [ Number ] [ l | b | c | k ] [ -f ] [ -r] [ 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 value for Number speci- fies how many units to write to standard output. The type of unit is determined by the -c, -n, -m, -b, or -k flag. If one of these flags is not specified, a default of 10 lines is used. Note: In the deprecated syntax, the b, c, k, or l flag is used to determine the type of units. A default of 10 units is used if Number is not specified. The value for Number can be a positive or negative integer. If the value is positive, the file is read starting at the specified number of units from the beginning of the file. If the value is negative, the file is read 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. Flags -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. By specifying the -f flag, the tail command can be used to moni- tor the growth of a file being written by another process. -b Number Reads the specified file beginning at the 512-byte block location indicated by the Number parameter. -k Number Reads the specified file beginning at the 1KB block lo- cation indicated by the Number parameter. -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. -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. Flags For Deprecated Syntax Number b Reads the specified file beginning at the 512-byte block location indicated by the Number parameter. Number c Reads the specified file beginning at the character lo- cation indicated by the Number parameter. -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 is specified and standard input is a pipe, the -f flag is ignored. By speci- fying the -f flag, the tail command can be used to monitor the growth of a file being written by another process. -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. Number k Reads the specified file beginning at the 1KB block lo- cation indicated by the Number parameter. Number l Reads the specified file beginning at the line location indicated by the Number parameter. Exit Status This command returns the following exit values: 0 Successful completion. >0 An error occurred. Examples 1. To display the last 10 lines of the notes file, enter: tail notes 2. To specify the number of lines to start reading from the end of the notes file, enter: tail -20 notes 3. To display the notes file a page at a time, beginning with the 200th byte, enter: tail -c +200 notes | pg 4. 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. Implementation Specifics Multibyte Language Support: 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 pro- duced that does not start on a character boundary. This command is part of Base Operating System (BOS) Runtime. Files /usr/bin/tail Contains the tail command. Related Information Input and Output Redirection Overview in AIX Version 3.2 System User's Guide: Base and Devices describes how the operating system processes input and output. Files Overview in AIX Version 3.2 System User's Guide: Base and Devices describes files, file types, and how to name files. The dd command, head command, more command, pg command.