[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可以显示.