| www.delorie.com/gnu/docs/sed/sed_7.html | search |
![]() Buy the book! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
Note: some implementations of sed, such as this one, will
double-print lines when auto-print is not disabled and the p
command is given.
Other implementations will only print the line once.
Both ways conform with the POSIX standard, and so neither
way can be considered to be in error.
Portable sed scripts should thus avoid relying on either behavior;
either use the `-n' option and explicitly print what you want,
or avoid use of the p command (and also the p flag to the
s command).
n
sed exits without processing
any more commands.
{ 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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |