擅长:python、mysql、java
<p>您需要将bash正在运行的任何程序的输出更改为无缓冲,而不是行缓冲。很多程序都有一个命令行选项来实现无缓冲输出。</p>
<p><a href="http://expect.sourceforge.net/#othertools" rel="nofollow noreferrer">expect</a>项目有一个名为<a href="http://expect.sourceforge.net/example/unbuffer.man.html" rel="nofollow noreferrer">^{<cd1>}</a>的工具,看起来它可以为您提供所有无缓冲的bash输出。我个人从来没有用过它,但是这里有其他的答案,所以也推荐它:<a href="https://stackoverflow.com/questions/3332045/bash-force-execd-process-to-have-unbuffered-stdout">bash: force exec'd process to have unbuffered stdout</a></p>