强制shell脚本fflush [英] Force a shell script to fflush

查看:939
本文介绍了强制shell脚本fflush的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能告诉bash中,为所有呼叫回声的printf 应随访通过向后续调用 fflush()在标准输出/标准错误分别?

I was wondering if it was possible to tell bash that all calls to echo or printf should be followed up by a subsequent call to fflush() on stdout/stderr respectively?

一个快速和肮脏的解决办法是写这样做我自己的printf的执行情况,并代替使用它可内置,但它发生,我认为我可能不需要。

A quick and dirty solution would be to write my own printf implementation that did this and use it in lieu of either built in, but it occurred to me that I might not need to.

我正在写一次运行多个构建脚本,用于调试需要我的真正的需要看到的是他们为了写邮件。

I'm writing several build scripts that run at once, for debugging needs I really need to see messages that they write in order.

推荐答案

如果命令对应使用标准输入输出,并连接到他们将每行刷新终端。
否则,你就需要使用上的命令类似stdbuf在管道
<一href=\"http://www.pixelbeat.org/programming/stdio_buffering/\">http://www.pixelbeat.org/programming/stdio_buffering/

If comands use stdio and are connected to a terminal they'll be flushed per line. Otherwise you'll need to use something like stdbuf on commands in a pipe line http://www.pixelbeat.org/programming/stdio_buffering/

这篇关于强制shell脚本fflush的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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