Tail Show end of file
1 , command format
Tail[option] ... [File] ...
2 , command functions
show file contents, display the file's 10 lines by default, you can use [-n] # | [-#] # represents the number of rows displayed, options specify how many rows to display
use tail command -f option for easy access to changing log files , tail -f filename filename , refresh display
3 , common options
- C # : Displays the bytes of the file ( character ) number
- N # : Shows how many lines of a file
- F : Cyclic display, when the content of the file changes, display the changed content, do not exit, wait for the next change
--pid=pid : With - F when the process ID die, PID dead process is over .
- s,--sleep-interval=n:Sleep (Hibernate), with- Fshared, when dormant.Nseconds before reading the contents of the specified file, each time reading hibernationNseconds
4 , command instance
1. View the contents of the file after N rows
[[Email protected]~]# cat Test 1 Askdasjkdhsak 2 hkjasd 3 hakjsd 4 HJAKSD 5 HAKSDLASDA S 6 kasdl[[email protected] ~] #tail-N 3 test hjaksdhaksdlasdaskasdl[[email protected]~]# tail-3 test hjaksdhaksdl Asdaskasdl[[email protected]~]#
2. cycle through the contents of a file
command: tail-f Ping.log
[[Email protected]~]# ping 172.16.2.2 >ping.log &[[email protected]~]# tail-f ping.log PING172.16.2.2 (172.16.2.2 ) bytes of data.64 bytesfrom 172.16.2.2:icmp_seq=1 ttl=64 time=0.028 ms64 bytesfrom 172.16.2.2:icmp_seq=2 ttl=64 time=0.034 ms64 bytes from172.16.2.2:icmp_seq=3 ttl=64 time=0.028 ms64 bytesfrom 172.16.2.2:icmp_seq=4 ttl=64 time=0.029 Ms64 bytesfrom 172.16.2.2:icmp_seq=5 ttl=64 time=0.028 ms ... [[Email protected]~]#
tip: ping 172.16.2.2 > ping.log & // in the background ping remote host. and output the file to ping.log ctrl + c to terminate.
3. start displaying files from Nth line
command: tail-n +# File
[[Email protected]~] #tail-n +3 test Askdasjkdhsakhkjasdhakjsd[[email protected]~]
This article is from "Linux rookie" blog, please be sure to keep this source http://geekb0y.blog.51cto.com/10743719/1883869
One day a linux base command view file at the beginning of the end of the content tail