Digital Sanctum

Personal blog of Shane Witbeck Tags · Archive · About

How to Replace HTML Links With Markdown Links Using sed

Published: 10 Sep 2020

Tools like Pandoc are great if you want to convert entire files from one format to another but if all you need is to replace links from one format to another sed is a great option.

Here’s a one-liner to do just that:

sed -i -E 's/<a[^>]*href="([^"]*)[^>]*>([^<]*)[^>]*>/[\2](\1)/g'
Tags: #sed#one-liner#html#markdown