Replace every odd or even occurance of a pattern in a file
I want to replace either every odd or even occurrence of a pattern. Look at the following example:
$ echo aaaaa | sed -e 's/a/b/' -e 's/a/c/' -e 's/a/b/' -e 's/a/c/' -e 's/a/b/'
bcbcb
Is there some command that can do this more concisely? What I'm actually doing is converting *s into BBCode [i] and [/i] tags, so if there's a markdown-to-BBCode converter out there, I'd like to hear about it too.
I want to replace either every odd or even occurrence of a pattern. Look at the following example:
$ echo aaaaa | sed -e 's/a/b/' -e 's/a/c/' -e 's/a/b/' -e 's/a/c/' -e 's/a/b/'
bcbcb
Is there some command that can do this more concisely? What I'm actually doing is converting *s into BBCode [i] and [/i] tags, so if there's a markdown-to-BBCode converter out there, I'd like to hear about it too.
No comments:
Post a Comment