View File and content processing-tail command, view processing-tail command
1. Command description:
The tail command is used to display the end Of the file content. By default, tail only displays the last 10 lines of the file.
2. Syntax:
Tail [Options]... [file list]...
3. instance:
Tail-n 5/var/log/messages? ? Displays the last five lines of the file. The-n option is used to specify the number of displayed rows.
[Root @ CentOS opt] # tail-n 5/var/log/messages ???? # Display the last 5 lines of content Feb 23 14:10:16 CentOS activation [629]: [system] Successfully activated service 'org. freedesktop. nm_dispatcher 'feb 23 14:10:16 CentOS release-daemon: activated [629]: [system] Successfully activated service 'org. freedesktop. nm_dispatcher 'feb 23 14:10:16 CentOS release EMD: Started Network Manager Script Dispatcher Service. feb 23 14:10:16 CentOS nm-dispatcher: req: 1 'dhcp4-change' [ens33]: new request (4 scripts) Feb 23 14:10:16 CentOS nm-dispatcher: req: 1 'dhcp4-change' [ens33]: start running ordered scripts... [root @ CentOS opt] #
However, the tail command also has a very practical function, that is, it can dynamically view the end of a file. This is very useful for viewing some constantly changing files. For example, there will be a lot of log files in the system, these files will change at any time, you need to dynamically view these files, the practical-f parameter can be done. For example, the/var/log/message file is the default system log file. The system will write a large number of logs into this file during running. You can use the following command, once a new log Content is written, this command displays the new content immediately.
Root @ CentOS opt] # tail-f/var/log/messages ???? #-F option can display the content at the end of a file in real time