3.5 The `s' Command
The syntax of the `s' (as in substitute) command is
`s/REGEXP/REPLACEMENT/FLAGS'. 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 `\'
The `s' command is probably the most important in `sed' and has a
lot of different options. Its basic concept is simple: the `s' command
attempts to match the pattern space against the supplied REGEXP; if the
match is successful, then that portion of the pattern space which was
matched is replaced with REPLACEMENT.
The REPLACEMENT can contain `\N' (N being a number from 1 to 9,
inclusive) references, which refer to the portion of the match which is
contained between the Nth `\(' and its matching `\)'. Also, the
REPLACEMENT can contain unescaped `&' characters which reference the
whole matched portion of the pattern space. Finally, as a GNU `sed'
extension, you can include a special sequence made of a backslash and
one of the letters `L', `l', `U', `u', or `E'. The meaning is as
Turn the replacement to lowercase until a `\U' or `\E' is found,
Turn the next character to lowercase,
Turn the replacement to uppercase until a `\L' or `\E' is found,
Turn the next character to uppercase,
Stop case conversion started by `\L' or `\U'.
To include a literal `\', `&', or newline in the final replacement,
be sure to precede the desired `\', `&', or newline in the REPLACEMENT
with a `\'.