[英]How do i remove the content between two patterns on multiple lines using sed?
This is the input 这是输入
hai people<PATTERN> we had
<PATTERN>a lot of fun<PATTERN>
writing scri pts
We will<PATTERN>
have more
<PATTERN>tomorrow<PATTERN>
Hurray!
Need to have 需要有
hai people<PATTERN> we had
writing scripts
We will<PATTERN>
have more
Hurray!
For me the first pattern match removes using the following command 对我来说,第一个模式匹配使用以下命令删除
sed '/PATTERN/{n;/PATTERN/d}' filename
grep -Pv '^<PATTERN>.*<PATTERN>$' input
hai people<PATTERN> we had
writing scri pts
We will<PATTERN>
have more
Hurray!
using sed
,although its an overkill: 使用sed
,尽管这是一个过大的杀伤力:
sed '/^<PATTERN>.*<PATTERN>$/d' input
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.