DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Editing files

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''.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 22 April 2004