我认为问题在于
grep缓冲其输出。当您管道操作时,它就是这样做的
tail -f | grep ... |some_other_prog。要
grep每行刷新一次,请使用以下
--line-buffered选项:
% tail -f data.txt | grep -e APL --line-buffered | test.pyAPLAPLAPL
在哪里
test.py:
import sysfor line in sys.stdin: print(line)
(已在gnome-terminal的Linux上进行了测试。)



