This is going to be installment one of quite a few little tricks and tips that I never seem to remember, and consequently alsways end up having to go out an research again. Hence, I'll now be blogging these little gems so they are in one place.
Sed is very useful for editing a stream (i.e. a file) on the fly. The most common thing I use it for is in a script in order to replace a setting in a file.
sed -e '/foo/s//bar/g' - replace all instances of foo (a regex) with bar. Note that the -e is not needed if there is only one "script" to process.
Update - Thanks to mat (see comments) for pointing out my fat fingering - sed -e '/foo/s/bar//g'
Found this useful? Then Digg It.

Comments (1)
sed -e '/foo/s/bar//g'
you sure about that?
what about
sed -e '/foo/s//bar/g' or
sed -e 's/foo/bar/g'
- s/regular expression/replacement/flags
Posted by mat | September 22, 2006 4:34 PM
Posted on September 22, 2006 16:34