NAME
ed - text editor
SYNOPSIS
ed [-p prompt] [-dsv] [file]
DESCRIPTION
ed initially reads its input file into a buffer. If no file argument is provided the buffer will be empty. Commands are then entered to display, modify and save the buffer. Line numbers within the buffer are referred to as addresses. Address 1 is the first line in the buffer; address 0 is invalid.
ed keeps track of the current line selected in the buffer. Commands for modifying the buffer can be entered without an explicit address; the current line will be processed. Entering a bare address such as "2" first resets the current line pointer, then prints the line.
Commands are denoted by a single letter. The "p" command prints one or more lines. An address can precede a command, so "2p" first resets the current line pointer then prints the line. This is the same result as for entering the bare address "2"; however, print is explicit.
A command may operate on a range of addresses at once. An address range is entered as two numbers separated by a comma, e.g. "1,10". The numbers are included as the first and last number of the range. So "1,10" spans from line 1 to 10. A range is then used as a command prefix, e.g. "1,2p" will print 2 lines. Addressing a line outside the scope of the buffer results in an error.
The commands "a", "c" and "i" allow text to be entered into the buffer. Text input is terminated by a line containing the single character ".". If an error occurs ed will print "?". The "h" command fetches the saved error message and prints it.
OPTIONS
The following options are available:
- -d
-
Print debugging information on standard output.
- -p STRING
-
Use the specified STRING as a command prompt. By default no prompt is displayed.
- -s
-
Suppress byte counts
- -v
-
Print full error messages; equivalent to the "H" command
EDITOR COMMANDS
- a
-
Append text
- c
-
Change text
- d
-
Delete text
- E FILE
-
Forced "e" command; suppress warning prompt
- e FILE
-
Load and edit the named FILE argument
- f [FILE]
-
Show/set a filename
- H
-
Toggle help mode; this causes descriptive errors to be displayed
- h
-
Display last error
- i
-
Insert text
- j
-
Join a range of lines into a single line. The current address is set to the destination address.
- l
-
Print lines with escape sequences for non-printable characters
- m
-
Move a range of lines to a new address. The current address is set to the last line moved.
- n
-
Print from buffer with line number prefix
- P
-
Toggle command prompt mode. A string provided by -p will be used; otherwise, the default is '*'
- p
-
Print from buffer
- Q
-
Forced "q" command; suppress warning prompt
- q
-
Quit program
- r FILE
-
Read named FILE into buffer
- s///
-
Substitute text with a regular expression
- t
-
Copy (transfer) lines to a destination address. The current address is set to the last line copied.
- W [FILE]
-
Write buffer to file in append mode
- w [FILE]
-
Write buffer to file
- =
-
Display current line number
AUTHOR
Written by George M Jones