Dud*_*ude 3 regex linux bash grep
我试图通过检查日志来调试一个场景,这是我的命令
tail -f eclipse.log | grep 'enimation' | grep -i 'tap'
Run Code Online (Sandbox Code Playgroud)
基本上我想要的是,在所有的线条中,我在其中打印带有enimation的线条,然后在所有动画中,我想看到带有"tap"的动画.
以下是返回空结果的sammple数据
*******enimation error*********TapExpand
*******enimation error*********TapShrink
Run Code Online (Sandbox Code Playgroud)
这将返回空结果.
如果我运行此命令
tail -f eclipse.log | grep -i 'enimation.*tap'
Run Code Online (Sandbox Code Playgroud)
它返回正确的结果.有人可以向我解释一下,上述两个命令之间有什么区别,以及为什么结果会有差异.它们看起来都和我一模一样.
grep正在缓冲它的输出.要告诉GNU grep 逐行吐出输出,你需要使用--line-bufferedoption grep来使它工作:
tail -f eclipse.log | grep --line-buffered 'enimation' | grep --line-buffered -i 'tap'
Run Code Online (Sandbox Code Playgroud)
按照man grep:
--line-buffered
Force output to be line buffered. By default, output is line buffered when standard
output is a terminal and block buffered otherwise.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
621 次 |
| 最近记录: |