Whether in sed or vi, when using the substitution
command, a delimiter is required to separate the search pattern
from the replacement string. The delimiter can be any character except
blank or a newline (vi seems to be more restrictive than
sed), although the usual
practice is to use the slash (
/) as a delimiter
When either the search pattern or the replacement string contains a slash, it is easier to change the delimiter character rather than escape the slash. Thus, if the pattern was attempting to match UNIX pathnames, which contain slashes, you could choose another character, such as a colon, as the delimiter:
Note that the delimiter appears three times and
is required after the replacement.
Regardless of which delimiter you use, if it does appear in the
regular expression, use a backslash (
\) to escape it.
If you don't know what characters the search pattern might have (in a shell program that handles any kind of input, for instance), the safest choice for the delimiter can be a control character. Article 45.35 shows how to make and use a control character as the delimiter in a shell script - without having to store the control character in the file.
You can use any delimiter for a pattern address (not just a slash).
Put a backslash (
\) before the first delimiter.
For example, to delete all lines containing /usr/mail, using
a colon (
:) as the delimiter: