unix command 'tail' lost option '--line-buffered'

懵懂的女人 提交于 2019-12-08 11:06:32

问题


With the last update of our SuSE Enterprise Linux 11 (now bash 3.2.51(1)-release), the command "tail" seems to have lost its option to stream files:

tail: unrecognized option '--line-buffered'

Our tail is from "GNU coreutils 8.12, March 2013". Is there another, equivalent solution?


回答1:


As far as can be told by simple googling, tail doesn't appear to have a --line-buffered option, grep does. --line-buffered is useful to force line buffering even when writing to a non-TTY, a typical idiom being:

tail -f FILE | grep --line-buffered REGEXP > output

Here the point of --line-buffered is to prevent grep from buffering output in 8K chunks and forcing the matched lines to immediately appear in the output file.

tail -f is unbuffered regardless of output type, so it doesn't need a --line-buffered option equivalent to the one in grep. This can be verified by running tail -f somefile | cat and appending a line to the file from another shell. One observes that, despite its standard output being a pipe, tail immediately flushes the newly arrived line.



来源:https://stackoverflow.com/questions/18227308/unix-command-tail-lost-option-line-buffered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!