3月 052015
 

问题

如下命令可以看到我们预期的输出:

如下命令不能看到预期的输出: (不是立即看到,其实,只要等等她就会来)

原因: 第一个grep命令buffer了输出

解决办法: 添加 –line-buffered 选项

 

同样, awk 也有类似问题,但是使用awk就没有添加选项这么幸运了;可以通过在awk的输出后面添加 system(“”); 来刷新buffer,如:

参考资料: http://unix.stackexchange.com/questions/33650/why-does-awk-do-full-buffering-when-reading-from-a-pipe

 

 Posted by at 上午 11:15

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据