kyprio kyprio - 1 year ago 92
Markdown Question

convert html links to markdown using command sed

I am editing a bash script to convert html into markdown and i found myself stuck with that tag :

<a href="">Link</a>

which should looks like this in markdown


Answer Source

I found something with sed and the pattern selectors \1 \2

echo '<a href="">Link</a>' | sed 's/<a href="\(.*\)">\(.*\)<\/a>/[\2](\1)/'

The pattern you place between parenthesis \( and \) will be stored in a variable \1 then the next one will be in \2 ...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download