Previous Table of Contents Next


Description:

The sed command copies files to standard output and edits them according to the given editing commands.

Options:

–e script execute commands in script
–f file get commands from file
–n suppress default output
files read standard input if no files given

Command Format:

        [address [ ,address ] ] commands [ arguments ]

execute commands for each input line that matches address or range of addresses. If commands is preceded by "!", input lines that do not match the address are used.

Addresses:

If no address is given, all input lines are matched.

Two addresses indicate a range.

. current line
$ last line
n nth line
/regular-expression/ regular expression
\n newline

Commands:

The maximum number of addresses listed in parentheses.

(1)a\ append the following text to the output text
(2)b label branch to the :label command. If label is empty, go to the end of the script.
(2)c\ change line text
(2)d delete lines
(2)D delete first line of input only
(2)g replace input lines with buffer contents
(2)G append buffer contents to input lines
(2)h replace buffer contents with input lines
(2)H append input lines to buffer contents
(1)i\ insert the following text text
(2)l display input lines
(2)n display input line; read next input line
(2)N append next input line to current line
(2)p display input lines
(2)P display first line of input line only
(1)q quit
(2)r file display contents of file
(2)s/RE/s/flags substitute s for the regular expression RE that matches input lines according to flags. The flags can consist of zero or more of:
n substitute for just the nth occurrence of the regular expression RE (1-512)
g substitute for all occurrences of RE
p display input line if substitution was made
w file append input line to file if substitution made
(2)t label branch to :label command if substitution was made. If label is empty, go to end of script.
(2)w file append input line to file
(2)x exchange input line with buffer contents
(2)y/s1/s2 replace characters in s1 with characters in s2. The lengths of s1 and s2 must be equal.
(2)!cmd execute command for the input lines not selected
(1) = display current line number
(2) { treat commands up to closing } as a group
(0)# interpret rest of input line as comments
(0)#n interpret rest of input line as comments and ignore


Previous Table of Contents Next
1