0

Hi folks a pleasure to write here. Nice to meet you.

I'm adding some feature to a markdown bash script that translate Markup to XHTML.

I'm searching for this pattern:

<p>
<img ...
</p>

If found I just want to live the <img> line. How could I do it?

Nice regards,

RG.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
taglio
  • 1
  • 2
  • [Don't Parse XML/HTML With Regex.](https://stackoverflow.com/a/1732454/3776858) I suggest to use an XML/HTML parser (xmlstarlet, xmllint ...). – Cyrus Apr 05 '20 at 07:28

1 Answers1

0

The solution is:

sed -n '/<img.*/{x;n;d;};1h;1!{x;p;};${x;p;}'
taglio
  • 1
  • 2