Version 8 of sed

Updated 2006-08-09 15:19:45

Stream Editor

A program that parses files or standard input, changes it according to a given set of rules, mostly based on Regular Expressions, and sends the new data to standard output. Unbelievably fast.

Erik Pemente keeps a very good amount of info and links in this page: http://www.student.northpark.edu/pemente/sed/ A spirited introduction to sed programming appears here [L1 ].

There is a page dedicated to the Tcl's implementation of Regular Expressions on this wiki. Tcl uses ARE. sed uses Basic and Extended Regular Expressions only.

One reason Tcl'ers encounter sed is that autoconf and autoconf-generated build scripts makes heavy use of sed to mangle text.


 $ sed s/foo/bar/ < infile > outfile

can in Tcl be substituted either with regsub or, when like in this case, no regular expression features are needed, with string map:

 % > outfile [regsub -all foo [< infile] bar]

resp.

 % > outfile [string map {foo bar} [< infile]]

where

 proc > {filename str} {set f [open $filename w]; puts $f $str; close $w}
 proc < {filename}     {set f [open $filename]; return [read $f][close $f]}

[ Category Acronym | Category Application ]