ed: Overview

1 
1 1 Overview
1 **********
1 
1 'ed' is a line-oriented text editor. It is used to create, display,
1 modify and otherwise manipulate text files. 'red' is a restricted 'ed':
1 it can only edit files in the current directory and cannot execute
1 shell commands.
1 
1    If invoked with a FILE argument, then a copy of FILE is read into
1 the editor's buffer. Changes are made to this copy and not directly to
1 FILE itself. Upon quitting 'ed', any changes not explicitly saved with
1 a 'w' command are lost.
1 
1    Editing is done in two distinct modes: "command" and "input".  When
1 first invoked, 'ed' is in command mode. In this mode commands are read
1 from the standard input and executed to manipulate the contents of the
1 editor buffer. A typical command might look like:
1 
1      ,s/OLD/NEW/g
1 
1    which replaces all occurences of the string OLD with NEW.
1 
1    When an input command, such as 'a' (append), 'i' (insert) or 'c'
1 (change), is given, 'ed' enters input mode. This is the primary means
1 of adding text to a file. In this mode, no commands are available;
1 instead, the standard input is written directly to the editor buffer. A
1 "line" consists of the text up to and including a <newline> character.
1 Input mode is terminated by entering a single period ('.') on a line.
1 
1    All 'ed' commands operate on whole lines or ranges of lines; e.g.,
1 the 'd' command deletes lines; the 'm' command moves lines, and so on.
1 It is possible to modify only a portion of a line by means of
1 replacement, as in the example above. However even here, the 's'
1 command is applied to whole lines at a time.
1 
1    In general, 'ed' commands consist of zero or more line addresses,
1 followed by a single character command and possibly additional
1 parameters; i.e., commands have the structure:
1 
1      [ADDRESS[,ADDRESS]]COMMAND[PARAMETERS]
1 
1    The ADDRESSes indicate the line or range of lines to be affected by
1 the command. If fewer addresses are given than the command accepts,
1 then default addresses are supplied.
1