![非贪婪删除多行](https://linux22.com/image/77065/%E9%9D%9E%E8%B4%AA%E5%A9%AA%E5%88%A0%E9%99%A4%E5%A4%9A%E8%A1%8C.png)
我有一个包含许多行的日志文件,例如:
2015-xx-yy bla bla
2015-11-09 23:59:18.167 Describe ▶ FOO
dummy
dummy
dummy
dummy
dummy
"BAR"
2015-xx-yy foo foo
2015-xx-yy bar bar
2015-xx-yy hello world
logged bla bla
2015-11-09 23:59:18.169 Describe ▶ FOO
dummy
dummy
dummy
dummy
dummy
"BAR"
如何删除从 到FOO
的行BAR
,以便仅保留其他行:
2015-xx-yy bla bla
2015-xx-yy foo foo
2015-xx-yy bar bar
2015-xx-yy hello world
logged bla bla
什么文本编辑器或程序可以轻松做到这一点?
答案1
一种方法是sed
:
sed -e '/FOO/,/BAR/d' <file