I search a command for keep only xml in a file, but i don't know how to make this.

I have searched regex, i have found this regex for find my content. (<msg>[\s\S]*?<\/msg>)

But i don't say how to integrate in sed for make this command in my programm: sed regex > myfile. Or better delete directly each line not matching with my regex.

My file:

MIME-Version: 1.0
Content-Type: Multipart/Related;boundary=MIME_boundary;

--MIME_boundary
Content-Type: application/xop+xml;

<msg><tag date="1557417027960" session="1697"><decision object="B04DWHEF" reliability="95" context="RO" x="796" y="371" width="89" height="18" direction="front"><jpeg></jpeg></decision></tag></msg>

Content-Type: application/octet-stream;
Content-Transfer-Encoding: binary;
Content-ID: A;
Content-Length: 30217;

����Lavc57.89.100��C...

I want only this result:

<msg><tag date="1557417027960" session="1697"><decision object="B04DWHEF" reliability="95" context="RO" x="796" y="371" width="89" height="18" direction="front"><jpeg></jpeg></decision></tag></msg>

1 Answers

0
Alexandre Lemaitre On Best Solutions

Thanks you Shubham for the regex, my solution for find only xml without other content in the same line is:

grep -o "<.*>.*</.*>" file_name