Home > Net >  Sed delete everything except text between 2 words in file
Sed delete everything except text between 2 words in file

Time:11-18

I have a file that includes an XML file and i need everything deleted except the text that starts with

<?xml version="1.0

and ends with

</martif>

Thanks you

I tried

sed '/<?xml version=/,$!d' file > result.txt

to delete everything until xml part but to delete from </martif> to the end i do not know how to achieve that.

CodePudding user response:

USe </martif> as the end of the range to print.

sed -n '/<?xml version=/,/<\/martif>/p' file.xml > result.txt
  • Related