Why do alternate delimiters not work with sed -e '/pattern/s/a/b/'?

Viewed 11129

Here is something I have discover that doesn't make sense.

Output of cat config.h:

define somevar foo // Sample variable

This version of the command works to change foo to bar and preserve the comments:

sed -e '/somevar/s/foo/bar/' config.h

This doesn't work:

sed -e '|somevar|s|foo|bar|' config.h

Gives this error:

sed: -e expression #1, char 1: unknown command: `|'

Funnily enough this does work:

sed -e '/somevar/s|foo|bar|' config.h

Perhaps I am missing some part of the documentation. It seems very odd to have two different delimiters in the same sed command.

Bug or feature?

5 Answers
Related