正则表达式 – grep的管道不适用于尾部?
发布时间:2020-12-14 05:37:26  所属栏目:百科  来源:网络整理 
            导读:参见英文答案 How to ‘grep’ a continuous stream?????????????????????????????????????11个 我试图通过检查日志来调试一个场景,这是我的命令 tail -f eclipse.log | grep 'enimation' | grep -i 'tap' 基本上我想要的是,在所有的线条中,我在其中打印带有
                
                
                
            | 
                         
 参见英文答案 > 
 How to ‘grep’ a continuous stream?????????????????????????????????????11个 
  
我试图通过检查日志来调试一个场景,这是我的命令 tail -f eclipse.log | grep 'enimation' | grep -i 'tap' 基本上我想要的是,在所有的线条中,我在其中打印带有enimation的线条,然后在所有动画中,我想看到带有“tap”的动画. 以下是返回空结果的sammple数据 *******enimation error*********TapExpand *******enimation error*********TapShrink 这将返回空结果. 如果我运行此命令 tail -f eclipse.log | grep -i 'enimation.*tap' 它返回正确的结果.有人可以向我解释一下,上述两个命令之间的区别是什么以及为什么结果存在差异.它们看起来都和我一模一样. 解决方法
 grep正在缓冲它的输出.要告诉GNU grep逐行吐出输出,你需要在grep中使用–line-buffered选项来使它工作: 
  
  
  
        tail -f eclipse.log | grep --line-buffered 'enimation' | grep --line-buffered -i 'tap' 按照男人的说法: --line-buffered
    Force output to be line buffered.  By default,output is line buffered when standard
    output is a terminal and block buffered otherwise.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  
