input.txt
:
blah1
blah2
start_pattern
blah3
blah4
blah5
end_pattern
blah6
blah7
I would like input.txt
to become:
blah1
blah2
end_pattern
blah6
blah7
I tried the following, but it didn't work.
sed -i "/start_pattern/, /end_pattern/{$!d}" input.txt
This question deals with your problem:
$ sed '/start_pattern/,/end_pattern/{/end_pattern/!d}' foo.txt
blah1
blah2
end_pattern
blah6
blah7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With