这是输入
hai people<PATTERN> we had
<PATTERN>a lot of fun<PATTERN>
writing scri pts
We will<PATTERN>
have more
<PATTERN>tomorrow<PATTERN>
Hurray!
需要
hai people<PATTERN> we had
writing scripts
We will<PATTERN>
have more
Hurray!
对我来说,使用以下命令删除第一个模式匹配
sed '/PATTERN/{n;/PATTERN/d}' filename
答案 0 :(得分:3)
grep -Pv '^<PATTERN>.*<PATTERN>$' input
hai people<PATTERN> we had
writing scri pts
We will<PATTERN>
have more
Hurray!
使用sed
,虽然它有点矫枉过正:
sed '/^<PATTERN>.*<PATTERN>$/d' input