On Tuesday, April 25th, I realized that I had set the tags in each blog post incorrectly. I thought they were delimited via commans, when they were actually delimited via an unordered list with the '-' character used as a bullet.
This is a common find/replace problem that can be solved in a variety of ways. It's a good simple problem to regularly solve. Also, it is easily mutated with different find/replace challenges.
The Problem-Statement
A series of blog post files have their tags set incorrectly.
Each file has a list of tags set via:
1 | --- |
When it should be:
1 | --- |
Programmatically fix this incorrect setup.
Mutations
Do It Backwards
Find/replace in the reverse order.
Switch:
1 | --- |
to:
1 | --- |
Sed One-Liner
First attempt did this with two sed commands. It can definitely be done in one.