Purpose
Write the file to the standard output from the specified point. You can use the-f option of the tail command to conveniently check the changing log file. The tail content of the filename is displayed on the screen and refreshed, so that you can see the latest file content.
Syntax
Standard syntax
Tail [-f] [-c Number |-n Number |-m Number |-B Number |-k Number] [File]
Display rows in reverse order
Tail [-r] [-n Number] [File]
Description
The tail command writes the File specified by the File parameter to the standard output starting from the specified point. If no file is specified, standard input is used. The Number variable specifies the Number of units to be written to the standard output. The value of the Number variable can be a positive or negative integer. If the value is preceded by a plus sign, the file is written to the standard output starting with the number of units specified at the beginning of the file. If there is a minus sign before the value, the file is written to the standard output starting from the number of units specified at the end of the file. If no + (plus sign) or-(minus sign) exists before the value, read the file starting from the specified unit number at the end of the file.
The Number variable determines the unit type of the start point of the count by the-B,-c,-k,-m, and-n flags. If no flag is specified, the tail command reads the last 10 lines of the specified file and writes it to the standard output. This is the same as entering-n 10 in the command line.
The-m flag provides consistent results in the single-byte and double-byte character environments. When the input is a text file containing multi-byte characters, use the-c flag with caution, because the output may not start from the character boundary.
Flag
-B Number
Reads the specified file from the location of the 512-byte block indicated by the Number variable.
-C Number
Reads the specified file from the byte location indicated by the Number variable.
-F
If the input File is a regular File or if the File parameter specifies FIFO (first-in-first-out), the tail command will not terminate after the last specified unit of the input File is copied, instead, read and copy additional units from the input file (when these units are available ). If the File parameter is not specified and the standard input is a pipe, the-f flag is ignored. The tail-f command can be used to monitor the growth of files being written by another process.
-K Number
Reads the specified file from the 1KB position indicated by the Number variable.
-M Number
Reads the specified file from the Multi-byte character position indicated by the Number variable. Use this flag to provide consistent results in the single-byte and double-byte character code set environments.
-N Number
Reads the specified file from the row location indicated by the Number variable.
-R
The output is displayed in reverse order from the end of the file. The default value of the-r flag is to print the entire file in reverse order. If the file is larger than 20,480 bytes, the-r flag only displays the last 20,480 bytes.
The-r flag is valid only when it is used together with the-n flag. Otherwise, it will be ignored.
Exit status
This command returns the following exit values:
0
Completed successfully.
> 0
An error occurs.
Example
To display the last 10 lines of the notes File, enter:
The number of rows to be read from the end of the notes File in tail notes. Enter:
Tail-n 20 notes
To display a page of notes files each time starting from 200th bytes, enter:
Tail-c + 200 notes | pg
To track file growth, enter:
Tail-f accounts
This shows the last 10 rows of the accounts file. The tail command continues to display the rows added to the accounts file. The display continues until you press Ctrl-C to stop.
File
/Usr/bin/tail
Contains the tail command.
Author 21 aspnet