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