3.1.3. Substitution switches
Standard versions of sed support 4 main flags or switches which may
be added to the end of an "s///" command. They are:
N - Replace the Nth match of the pattern on the LHS, where
N is an integer between 1 and 512. If N is omitted,
the default is to replace the first match only.
g - Global replace of all matches to the pattern.
p - Print the results to stdout, even if -n switch is used.
w file - Write the pattern space to 'file' if a replacement was
done. If the file already exists when the script is
executed, it is overwritten. During script execution,
w appends to the file for each match.
GNU sed 3.02 and ssed also offer the /I switch for doing a
case-insensitive match. For example,
echo ONE TWO | gsed "s/one/unos/I" # prints "unos TWO"
GNU sed 4.x and ssed add the /M switch, to simplify working with
multi-line patterns: when it is used, ^ or $ will match BOL or EOL.
\` and \' remain available to match the start and end of pattern
ssed supports two more switches, /S and /X, when its Perl mode is
used. They are described in detail in section 6.7.3.H, below.