ed(1) | ed(1) |
NAME
ed, red -
SYNOPSIS
ed
DESCRIPTION
The ed command executes a
If ®le is speci®ed, ed performs an e command (see below) on the named ®le; that is to say, the ®le is read into ed's buffer so that it can be edited.
Options
The following options are recognized:
Perform an X command ®rst to handle an encrypted ®le. |
File Handling
ed operates on a copy of the ®le it is editing; changes made to the copy have no effect on the original ®le until a w (write) command is given. The copy of the text being edited resides in a temporary ®le called the buffer. There is only one buffer.
red is a restricted version of ed that only allows editing of ®les in the current directory and prohibits executing shell commands via
Both ed and red support the fspec(4) formatting capability. After including a format speci®cation as the ®rst line of ®le and invoking ed with the controlling terminal in stty
<:t5,10,15 s72:>
the tab stops would be set at columns 5, 10, and 15, and a maximum line length of 72 would be imposed.
Note: When you input text, ed expands tab characters as they are typed to every eighth column as a default.
Editor Commands Structure
Commands to ed have a simple and regular structure: zero, one, or two addresses followed by a single- character command, possibly followed by parameters to that command. These addresses specify one or more lines in the buffer. Every command that requires addresses has default addresses, so that the addresses can very often be omitted.
In general, only one command is allowed on a line. Append, change, and insert commands accept text input which is then placed in the buffer as appropriate. While ed is accepting text following an append, change, or insert command, it is said to be in input mode. While in input mode, no editor commands are recognized; all input is merely collected. To terminate input mode, type a period (.) alone at the beginning of a line.
Regular Expressions
ed supports the Basic Regular Expression (RE) syntax (see regexp(5)), with the following additions:
∙The null RE (for example, //) is equivalent to the last RE encountered.
∙If the closing delimiter of an RE or of a replacement string (for example, /) would be the last char- acter before a newline, that delimiter can be omitted, in which case the addressed line is printed. The following pairs of commands are equivalent:
− 1 − | Section 1−195 |
e