I have been exploring using sed to achieve a number of text manipulations in the course of rolling out a number of new Jekyll based websites.
Recently I have been working on streamlining the process of moving from the pre TheAudioPodcast show notes to the podcast feed notes after the show is recorded. The required differences between the files is achieved through the use of this single sed command.
sed -e "s/v2post/post #v2post/g" -e "s_permalink: /show/\([0-9]*\)/_permalink: /show/\1.html_" $FILENAME > output-$FILENAME
The command changes the yaml front matter in two ways. Firstly the command,
changes all values ‘v2post’ into ‘post #v2post’.
Secondly the command,
"s_permalink: /show/\([0-9]*\)/_permalink: /show/\1.html_"
changes the permalink yaml entry from ‘/show/99/’ in to ‘/show/99.html’.
The second command also demonstrated the ability to choose the command delimiter for sed. The first command uses ‘/’ while the second command uses ‘_’.