Sed -e 's///g' or sed -e 's|||g'

Hi forum,

Why does the vertical line work too?

$ echo “foo” | sed -e ‘s/foo/FOO/g’

$ echo “foo” | sed -e ‘s|foo|FOO|g’

$ sed --version
sed (GNU sed) 4.5


See sed, a stream editor

The / characters may be uniformly replaced by any other single character within any given s command. The / character (or whatever other character is used in its stead) can appear in the regexp or replacement only if it is preceded by a \ character.

1 Like