如何使尾部仅显示具有特定文本的行?如果搜索条件可以是正则表达式,那就更好了.我需要这样的东西:tail -f mylogfile.log showOnlyLinesWith "error: "
我正在运行Darwin(Mac OS X),而且我在bash中完全是初学者.
- 非常感谢advace
小智 38
你可以做
tail -f mylogfile.log | grep "error: "
Run Code Online (Sandbox Code Playgroud)
这也适用于正则表达式.通常,您可以获取任何命令的输出,将|
其"管道" 添加到grep,然后让grep过滤掉与某个模式不匹配的行.