next up previous
Next: The Shell Script Up: Programs Using Regular Expressions Previous: RE in vi:

RE in sed:

SED means a Stream EDitor. SED does not change the file it edits. It takes data from standard input or a file, transforms them and passes them into a standard output. The UNIX command is sed and we will show only a few examples of its application for finding or replacing a string in the given text. More detailed description can be found in UNIX in a nutshell.

Assume that we want to replace all occurrences of t.*ing in temp with HELLO. We can do so using:
cat temp $\vert$ sed 's/t.*ing/HELLO/g'
or
sed 's/t.*ing/HELLO/g' temp
Notice that the longest match is replaced.
Output goes to stdin.



Instructional Support Group 2008-08-05