
758
|
Chapter 10: The sed Editor
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Braces ({}) are used in sed to nest one address inside another or to apply multiple
commands at a single matched address:
[/pattern/[,/pattern/]]{
command1
command2
}
The opening curly brace must end its line, and the closing curly brace must be on
a line by itself. Be sure there are no spaces after the braces.
GNU sed Regular Expression Extensions
With the -r option, GNU sed uses Extended Regular Expressions instead of Basic
Regular expressions. (See Chapter 7 for more information.) However, even
without -r, you can use additional escape sequences for more powerful text
matching. The following escape sequences are valid only in regular expressions:
\b Matches on a word boundary, where of the two surrounding characters (x\by),
one is a word-constituent character and the other is not.
\B Matches on a non-word boundary, where both of the two surrounding char-
acters (x\by) are either word-constituent or not word-constituent.
\w Matches any word-constituent character (i.e., a letter, digit, or underscore).
\W Matches any non-word-constituent character (i.e., anything that is not a
letter, digit, or underscore).
\` Matches the beginning of the pattern space. This is different from ^ when the
m modifier is used for a pattern or the s command.
\' Matches the end of ...