时间:2023-03-09来源:系统城装机大师作者:佚名
在日常的开发过程中,我们利用grep可以方便快捷的查找感兴趣的日志内容,极大地提升了开发和排错效率。但是有时候,我们也会遇到一些问题,比如。
| 1 2 3 4 5 6 7 8 9 10 11 |
tail -f crazy.log | grep HelloHello,printting from RubyHello,Time is 1566096393Hello,printting from RubyHello,Time is 1566096393Hello,printting from RubyHello,Time is 1566096393Hello,printting from RubyHello,Time is 1566096393Hello,printting from RubyHello,Time is 1566096393 |
那么当我们再次增加一个过滤是,却没有内容(立即)产生了
| 1 | ➜ /tmp tail -f crazy.log | grep Hello | grep Time |
| 1 2 3 4 5 6 |
tail -f crazy.log | grep --line-buffered Hello | grep TimeHello,Time is 1566096393Hello,Time is 1566096393Hello,Time is 1566096393Hello,Time is 1566096393Hello,Time is 1566096393 |
如上,我们使用grep的选项--line-buffered即可。
--line-buffered
Force output to be line buffered. By default, output is line buffered when standard output is
a terminal and block buffered otherwise.
上面的意思是
所以,这也就解释了为什么双重grep过滤没有内容,因为没有达到块缓冲限制。
以上。
2024-07-07
myeclipse怎么导入tomcat教程2024-07-07
myeclipse如何启动tomcat2024-07-07
myeclipse如何绑定tomcat上线了一个小的预约程序,配置通过Nginx进行访问入口,默认的日志是没有请求时间的,因此需要配置一下,将每一次的请求的访问响应时间记录出来,备查与优化使用....
2023-03-17