DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Using ed

Editing text in ed

There are several commands for editing text in ed:


a
Appends text. If the file is new, you can only enter text using this command. If the file already exists, specify an address (in the form of a line number or search pattern) to select the line to which to append text.

c
Changes text. This command requires the address(es) of the line(s) to be replaced. When you finish entering new text, press <Ctrl>D or ``.'' on a new line to return to command mode.

d
Deletes text. This command requires the address(es) of the line(s) to be deleted.

i
Inserts text. Whatever you type is inserted before the current line; press <Ctrl>D or ``.'' on a new line to stop inserting text and return to command mode.

s/old/new
Replaces text. ed replaces the first occurrence of old on the line with new. The string old can contain regular expressions, as with vi.

If you prefix this command with a range of addresses, each line in the range is searched and the first instance of old on each line is replaced with new. For example, ,s/foo/bar/g replaces every instance of ``foo'' on every line by the string ``bar''.


u
Cancels the effect of the previous command.
ed supports the same regular expressions as vi; see ``Editor regular expressions''. For full details, see also regexp(M).
Previous topic: Moving around in ed

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