If the head command is used to view the header of the file, then the tail command is just the opposite. The tail command is mainly used to view the end of the file content. The following small series will give you a detailed introduction to the use of tail under Linux.
1. Command format;
tail[required parameter][select parameter][file]
2. Command function:
Used to display the content at the end of the specified file. When no file is specified, it is processed as input information. Commonly used to view log files.
3. Command parameters:
-f Loop read
-q Do not display processing information
-v Display detailed processing information
-c"Number" Number of bytes displayed
-n "Number of lines" Display the number of lines
--pid=PID is used in conjunction with -f to indicate that the process ID and PID have died.
-q, --quiet, --silent Never output the header given the file name
-s, --sleep-interval=S with -f, indicating that each time Repeated interval sleep S seconds
4. Example:
Instance 1: Displaying the end of the file
Command:
tail -n 5 log2014.log
Output:
[root@localhost test]# tail -n 5 log2014.log
2014-09
2014-10
2014-11
2014- 12
=====================================[root@localhost test]#
Description:
Displaying the last 5 lines of the file
Example 2: Looping through the contents of the file
Command:
tail -f test.log
Output:
[root@localhost ~]# ping 192.168.120.204 》 test.log &
[1] 11891[root@localhost ~]# tail -f test. Log
PING 192.168.120.204 (192.168.120.204) 56(84) bytes of data.
64 bytes from 192.168.120.204: icmp_seq=1 ttl=64 time=0.038 ms
64 bytes from 192.168.120.204: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 192.168.120.204: icmp_seq=3 ttl=64 time =0.033 ms
64 bytes from 192.168.120.204: icmp_seq=4 ttl=64 time=0.027 ms
64 bytes from 192.168.120.204: icmp_seq=5 ttl=64 time=0.032 ms< Br>
64 bytes from 192.168.120.204: icmp_seq=6 ttl=64 time=0.026 ms
64 bytes from 192.168.120.204: icmp_seq=7 ttl=64 time=0.030 ms
64 bytes from 192.168.120.204: icmp_seq=8 ttl=64 time=0.029 ms
64 bytes from 192.168.120.204: icmp_seq=9 ttl=64 time=0.044 ms
64 bytes from 192.168.120.204: icmp_seq=10 ttl=64 time=0.033 ms
64 bytes from 192.168.120.204: icmp_seq=11 ttl=64 time=0.027 ms
[root@localhost ~]#
Description:
ping 192.168.120.204 》 test.log & //ping the remote host in the background. And output the file to test.log; this method is also used for more than one file monitoring. Use Ctrl+c to terminate.
Example 3: Displaying files starting from line 5
Command:
tail -n +5 log2014.log
Output:
[root@localhost test]# cat log2014.log
2014-01
2014-02
2014-03
2014-04< Br>
2014-05
2014-06
2014-07
2014-08
2014-09
2014-10
2014-11
2014-12
======================== =======
[root@localhost test]# tail -n +5 log2014.log
2014-05
2014-06
2014-07
2014-08
2014-09
2014-10
2014-11
2014-12
================================================================================= Introduced, if you need to view the last few lines of the file, then you will use the tail command, you can refer to the above examples combined with the actual use.
Is still a headache for not knowing how to use grep command, if you pass the instance, you can bette
If you dont embed a font when you create a PDF file, it may cause different styles
In a virtual machine, the Linux system needs to be configured to install a local yu
VPN is a virtual private network. It has the characteristics of low cost and easy t
How to configure dynamic IP service for Linux system
Linux method for building pipe pipeline functions
Linux beginners need to learn the summary of commands
Linux scp command usage example summary
Linux uses PXE to install virtual machines
Ubuntu can't connect to Windows Phone solution
How to turn off alt shortcuts in Ubuntu system
How to use the Linux cd command?
Linux accidentally delete the log file syslog how to do?
Windows10 official version boot is very slow, what should I do?
Win8 media platform: higher low-power experience
What is the use of the cloud cloud disk?
Win10 Mobile Preview 10581: QQ, WeChat send pictures are still not perfect
Tips: Win8/Win8.1 to retrieve WD right-click scanning function
Win10 official home version users may be forced to download and install system updates
Website Technology-SERV-U FTP Little-known Skills
What should I do if Win8 has 0x800F0906 error when installing .NET 3.5?
Win7 system can not read the CD when burning, please insert the CD problem solution