September 2009
Beginner
942 pages
85h 34m
English
Command | Action performed |
|---|---|
s/xx/yy/g | Substitute on all lines (all occurrences). |
/BSD/d | Delete lines containing BSD. |
/^BEGIN/,/^END/p | Print between BEGIN and END, inclusive. |
/SAVE/!d | Delete any line that doesn’t contain SAVE. |
/BEGIN/,/END/!s/xx/yy/g | Substitute on all lines, except between BEGIN and END. |
Braces ({ }) are used in sed to nest one address inside another or to apply multiple commands at a single matched address:
[/pattern/[,/pattern/]]{command1command2}
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.