4.4. Commands and Options
Sed commands tell sed how to process each line of input specified by an address. If an address is not given, sed processes every line of input. (The % is the csh prompt.) See Table 4.1 for a list of sed commands and what they do, and see Table 4.2 for a list of options and how they control sed's behavior.
Example 4.2.
% sed '1,3d' file
|
EXPLANATIONSed will delete lines 1 through 3. |
Command | Function |
---|---|
a\ | Appends one or more lines of text to the current line. |
c\ | Changes (replaces) text in the current line with new text. |
d | Deletes lines. |
i\ | Inserts text above the current line. |
h | Copies the contents of the pattern space to a holding buffer. |
H | Appends the contents of the pattern space to a holding ... |
Get UNIX® Shells by Example, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.