使用sed删除匹配的正则表达式及其下一行(或两行) [英] Use sed to delete a matched regexp and the line (or two) underneath it
本文介绍了使用sed删除匹配的正则表达式及其下一行(或两行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,我发现了这个问题:
OK I found this question:
并花了最后一个小时尝试编写与字符串匹配的内容,并删除包含该字符串的行及其下的行(或一种变体-删除其下的两行).
and just spent the last hour trying to write something that will match a string and delete the line containing the string and the line beneath it (or a variant - delete 2 lines beneath it).
我觉得我正在输入随机字符串.请有人帮我.
I feel I'm now typing random strings. Please somebody help me.
推荐答案
如果我正确理解了这一点,请删除匹配行和之后的一行
If I've understood that correctly, to delete match line and one line after
/matchstr/{N;d;}
匹配行和后两行
/matchstr/{N;N;d;}
-
N
引入下一行 -
d
-删除结果单行 N
brings in the next lined
- deletes the resulting single line
这篇关于使用sed删除匹配的正则表达式及其下一行(或两行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文