|
tail
Displays last few lines ( default: 10 lines ) of text in a file( 显示一个纯文本的后几行内容,默认为10行).用法(经常用来查看文件中新增的资料):
Use -n or --lines to change number of lines displayed(和 head 类似)
Use -f to follow the end of a text file as it changes (使用 -f 参数非常适合用来查看 log 文件(-f 可以跟随着 log 文件的变化而即时的显示出来) )
tail -f will continue to show updates of the file until <ctrl-c> is pressed ( tail -f 持续的显示出文件中被更新的内容直到按下 ctrl + c )用法示例:
tail -f /etc/log/messages
这时,光标会在文件的末尾停留并闪烁(其意是等待 messages 文件因为某些操作而写入时,被写入的新内容会立马显示出来 )。于是,下面尝试输入:
service network restart /*重启网络服务,相当于windows中的网卡禁用再启用*/
指令执行完后,在 执行 tail -f 指令窗口会马上看到日志内容的变化,如:Nov 23 16:36:32 linux-beyes ifdown: eth0 device: Marvell Technology Group Ltd. 88E8053 PCI-E Gigabit Ethernet Controller (rev 22)
Nov 23 16:36:32 linux-beyes dhcpcd[2770]: eth0: received SIGTERM, stopping
Nov 23 16:36:32 linux-beyes dhcpcd[2770]: eth0: removing default route via 192.168.1.1 metric 0
..... .... .... .... ... |
|