Dynamic display of File content commands

Source: Internet
Author: User

Dynamic display of File content commands

How does the Linux system dynamically display the contents of a file using the command line? In general, the service logs in the Web system are text-based and are scrolling all the times. If we're just starting or monitoring, it's a hassle to open the file every time, so let's look at a better way to do it.

Preparatory work

1, first, through SSH on a *nix, the demo directory, here is assumed to be/home/duser/demo, and a copy of a file called Demo.txt, which says the first line of Hello world.

2. Next, you need to know the commands that will be used. Head file: Displays the first 10 lines; tail File: Displays the last 10 rows;

Using the tail file command

1, below we use tail demo.txt command to look at the effect. Careful will find that after this command is displayed, it will soon exit the current command, indicating that it does not automatically scroll.

2, below we use tail-f demo.txt command to look at the effect. In the diagram, we can see that the command has been suspended, indicating that it waits for a change and then outputs.

3, then we open demo.txt direct editing, random input, remember to save. How, is it possible to view it dynamically.

4, sometimes, the default display of 10 lines of information is too small, then we use the-n parameter, to increase its display line number, here we example 10 lines and 20 lines between the difference.

5. Finally, if you want to learn more, you can get more by entering the command tail--help .

Dynamic display of File content commands

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.