unix 命令“tail"丢失选项“--line-buffered" [英] unix command 'tail' lost option '--line-buffered'

查看:61
本文介绍了unix 命令“tail"丢失选项“--line-buffered"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着我们的 SuSE Enterprise Linux 11(现在是 bash 3.2.51(1)-release)的最后一次更新,命令tail"似乎失去了流式传输文件的选项:

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'

我们的尾巴来自GNU coreutils 8.12, March 2013"​​.还有其他等效的解决方案吗?

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

推荐答案

就简单的谷歌搜索可以看出,tail 似乎没有 --line-buffered 选项,grep 可以.--line-buffered 即使在写入非 TTY 时也可用于强制行缓冲,典型的习惯用法是:

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

这里 --line-buffered 的重点是防止 grep 以 8K 块缓冲输出并强制匹配的行立即出现在输出文件中.

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 无论输出类型如何都是无缓冲的,因此它不需要与 grep<中的选项等效的 --line-buffered 选项/代码>.这可以通过运行 tail -f somefile | 来验证.cat 并从另一个 shell 向文件追加一行.有人观察到,尽管它的标准输出是一个管道,tail 会立即刷新新到达的行.

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.

这篇关于unix 命令“tail"丢失选项“--line-buffered"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆