[20170607]tail -F.txt

[20170607]tail -F.txt

--//如果你看man tail文档,可以发现-F 与 -f 非常相似,但是存在一点点区别.

-f, --follow[={name|descriptor}]
      output appended data as the file grows; -f, --follow, and --follow=descriptor are equivalent

-F     same as --follow=name --retry


--//-F 多了一个--retry,也就是文件删除后或者被截断后依旧可以使用.通过例子来说明:

1.测试-f:
--//终端1:
$ touch a.log
$ tail -f a.log

--//终端2:
$ echo 1111 >| a.log

--//终端1:
$ tail -f a.log
1111

--//终端2:
$ echo 2222 >> a.log

--//终端1:
$ tail -f a.log
1111
2222

--//终端2:
$ echo aaaa >| a.log

--//终端1:
$ tail -f a.log
1111
2222
tail: a.log: file truncated

--//终端2:
$ echo bbbb >> a.log

--//终端1:
$ tail -f a.log
1111
2222
tail: a.log: file truncated
bbbb

--//终端2:
$ rm a.log
/bin/rm: remove regular file `a.log'? y
$ echo cccc > a.log

--//终端1:
$ tail -f a.log
1111
2222
tail: a.log: file truncated
bbbb

--//可以发现不输出cccc.

2.测试-F.
--//实际上2者的差别就在于删除文件,再加入内容后,tail -F可以显示.

--//终端1:
$ tail -F a.log
cccc

--//终端2:
$ rm a.log
/bin/rm: remove regular file `a.log'? y

--//终端1:
$ tail -F a.log
cccc
tail: `a.log' has become inaccessible: No such file or directory

--//终端2:
$ echo dddd >>a.log

--//终端1:
$ tail -F a.log
cccc
tail: `a.log' has become inaccessible: No such file or directory
tail: `a.log' has appeared;  following end of new file
dddd

--//删除文件后在建立加入内容-F可以显示.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值