sed

From Initq

Jump to: navigation, search

sed (Stream EDitor) refers to a Unix utility for parsing text files and the programming language it uses to apply textual transformations to a sequential stream of data. It reads input files line by line, applying the operation which has been specified via the command line (or a sed script), and then outputs the line. It was developed from 1973 to 1974 as a Unix utility by Lee E. McMahon of Bell Labs[1], and is available today for most operating systems.The sed command directly modifies the content of files, sending the changed file to stdout.

 sed [options] -f script-file [input-file]
 sed [options] script-text [input-file]
Command Addresses Meaning
= 0 or 1 Display the current line number
a\text 0 or 1 Append text to the file
i\text 0 or 1 Insert text into the file
r filename or 1 Append text from filename into the file
c\text range replace the selected range
s/regexp/replacement range replace text that matches the regular expression (reqexp) with replacement
Personal tools