DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Manipulating text with sed

Using sed

sed reads its standard input a line at a time, carries out whatever editing changes are specified, then writes the changed lines to its output. It acts as a filter on the input file, which streams through it.

How sed works

To use sed, you need to specify the name of the command file that contains your editing script, then the file or files that you are processing. For example:

sed -f editscript <inputfile >outputfile
sed -e "/Hello/s/Hello/Hi/g" <letter.old >letter.new

Three optional flags are recognized on the command line:


-n
Directs sed to copy only those lines specified by p functions or p flags after s functions. See ``Whole-line oriented functions'' for details.

-e
Indicates that the next argument is an editing command.

-f
Indicates that the next argument is the name of the file which contains editing commands, typed one to a line.

Next topic: Writing sed commands
Previous topic: What is sed?

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005