Next: The "s" Command, Previous: Regular Expressions, Up: sed Programs
If you use sed at all, you will quite likely want to know these commands.
#
The #
character begins a comment;
the comment continues until the next newline.
If you are concerned about portability, be aware that
some implementations of sed (which are not posix
conformant) may only support a single one-line comment,
and then only when the very first character of the script is a #
.
Warning: if the first two characters of the sed script
are #n
, then the -n (no-autoprint) option is forced.
If you want to put a comment in the first line of your script
and that comment begins with the letter ‘n’
and you do not want this behavior,
then be sure to either use a capital ‘N’,
or place at least one space before the ‘n’.
q [
exit-code]
Exit sed without processing any more commands or input.
Note that the current pattern space is printed if auto-print is
not disabled with the -n options. The ability to return
an exit code from the sed script is a GNU sed extension.
d
p
n
{
commands }
{
and }
characters.
This is particularly useful when you want a group of commands
to be triggered by a single address (or address-range) match.