DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Manipulating text with sed

Writing sed commands

The general format of a sed editing command is:

[address1[,address2]] function [arguments]

An address is a parameter which tells sed which lines to apply the function to. Addresses may be line numbers or regular expressions. If two addresses are specified, sed applies the function to all the lines in the range from address1 to address2. You can omit one or both addresses; in the absence of an address sed applies the function to every line that it reads. For example, the following script turns every occurrence of ``red'' into ``blue'' throughout a file:

s/red/blue

The function determines the operation that sed carries out on the matching line. A function is always required in a command, but arguments are optional for some functions.

Any number of blanks or tabs can separate the addresses from the function, and tab characters and spaces at the beginning of lines are ignored.


Next topic: How sed commands are carried out
Previous topic: Using sed

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005