bash – egrep匹配组不打印?

前端之家收集整理的这篇文章主要介绍了bash – egrep匹配组不打印?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试创建一个bash脚本,它将使用egrep从文件中grep行.我创建了应该将我想要的信息分组的正则表达式,问题是尝试获取输出.我一直用以下命令测试它,但运行时没有打印.如何在 – {80}和断开连接之间打印多行?
egrep -E "^-{80}$\r?\n?([:ascii:]*)Disconnected from Server" testing.txt

文件:testing.txt

Connected to the server: name here

Some header text.
More text to go though...
--------------------------------------------------------------------------------
The information that I want,would be in here;

Including this line as well #$
and this one.

Disconnected from Server...
你可能最好使用像awk这样的工具.
awk '/^----+$/ {flag=1;next} /Disconnected from Server/{flag=0} flag {print}'

见:http://nixtip.wordpress.com/2010/10/12/print-lines-between-two-patterns-the-awk-way/

原文链接:https://www.f2er.com/bash/385264.html

猜你在找的Bash相关文章