曲径通幽论坛

 找回密码
 立即注册
搜索
查看: 5217|回复: 0
打印 上一主题 下一主题

tail -----------查看文本内容

[复制链接]

4918

主题

5880

帖子

3万

积分

GROAD

曲径通幽,安觅芳踪。

Rank: 6Rank: 6

积分
34397
跳转到指定楼层
楼主
发表于 2008-11-23 16:38:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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 类似)
tail -5 /etc/passwd   

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

..... .... .... .... ...
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|曲径通幽 ( 琼ICP备11001422号-1|公安备案:46900502000207 )

GMT+8, 2025-6-18 14:32 , Processed in 0.063055 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表