Article 4VBKS Sed remove between patterns

Sed remove between patterns

by
pedropt
from LinuxQuestions.org on (#4VBKS)
This code is probably here already in the forum , but search engine did not poped up any results for what i need .

And what i need is pretty simple , use sed to remove everything between 2 patterns , but do not remove the patterns .

Example :


#starthere
dwfwef
efewf
wefewf
#endhere

Desired output

#starthere
#endhere

This next code removes also the patterns , but i dont want them to be removed , i want only what there is between them .
Code:sed -i "/\#starthere/,/\#endhere/d" myfilelatest?d=yIl2AUoC8zA latest?i=QtPa6vyuCYc:BQdvcHJfrKY:F7zBnMy latest?i=QtPa6vyuCYc:BQdvcHJfrKY:V_sGLiP latest?d=qj6IDK7rITs latest?i=QtPa6vyuCYc:BQdvcHJfrKY:gIN9vFwQtPa6vyuCYc
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments