View File and content processing-tail command, view processing-tail command

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.