Displays the last few lines of a file.
To Display Lines in Reverse Order
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.
|-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 from the first or last line location as indicated by the sign (+ or - or none) of the Number variable and offset by the number of lines Number.|
|-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.|
This command returns the following exit values:
|>0||An error occurred.|
- To display the last
10 lines of the notes file, enter:
- 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 accountsThis 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.
|/usr/bin/tail||Contains the tail command.|