Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiline trimming

Tags:

linux

unix

sed

awk

I have a html file that I want to trim. I want to remove a section from the beginning all the way to a given string, and from another string to the end. How do I do that, preferably using sed?

like image 265
Igor Avatar asked Dec 06 '25 06:12

Igor


1 Answers

With GNU sed:

sed '/mark1/,/mark2/d;/mark3/,$d'

this

abc
def
mark1
ghi
jkl
mno
mark2
pqr
stu
mark3
vwx
yz

becomes

abc
def
pqr
stu
like image 77
Dennis Williamson Avatar answered Dec 08 '25 21:12

Dennis Williamson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!