如何使用sed删除与模式匹配的行及其后的行? [英] How to delete the line that matches a pattern and the line after it with sed?

查看:64
本文介绍了如何使用sed删除与模式匹配的行及其后的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的文件:

I have a file that looks something like:

good text
good text
FLAG bad text
bad text
good text
good text
good test
bad Text FLAG bad text
bad text
good text

我需要删除任何包含"FLAG" 的行,并且我总是也需要删除紧接在"FLAG"行之后的一行.

I need to delete any line containing "FLAG" and I always need to delete the one line immediately following the "FLAG" line too.

"FLAG"行不规则地出现,以至于我不能依靠任何种类的行号策略.

"FLAG" lines come irregularly enough that I can't rely on any sort of line number strategy.

有人知道如何用sed做到这一点吗?

Anyone know how to do this with sed?

推荐答案

使用

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆