0

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
doppelgreener
  • 4,809
  • 10
  • 46
  • 63

1 Answers1

3
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  '/^<PATTERN>.*<PATTERN>$/d' input
P....
  • 17,421
  • 2
  • 32
  • 52