sed the Stream EditorThis uses editing commands that have the same form as the line editor
ed and the visual editor, vi. One application
of sed is "search and replace" operations on whole
files, or sets of files. The general form of a sed command
is
sed 'list of editing commands' filename(s)
Example
To change the word hedge in a file to wart
the substitute option, s, can be used:
sed 's/hedge/wart/g' verse1
The g at the end of the editing commands means "global",
i.e. change all occurrences on that line. This command writes the resulting
lines to the screen. To write to a file, redirect:
sed 's/hedge/wart/g' verse1 > verse1.wart
Regular expressions as defined for grep, can also be used
with sed. Quite complex scanning can be performed by sed,
with the constraint that only a single pass through the input file is made.
Help: for more information see sed(1), vi(1) and ed(1).