我有一个包含许多行的日志文件,例如:
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