home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 6
/
FreshFish_September1994.bin
/
gnu
/
info
/
ed.info
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1994-09-02
|
24KB
|
458 lines
This is Info file ed.info, produced by Makeinfo-1.55 from the input
file ed.texinfo.
This file documents the `ed' command, which has the purpose of
editing text files.
Copyright (C) 1993 by the Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the Foundation.
File: ed.info, Node: Top, Next: Description, Prev: (dir), Up: (dir)
This file documents the `ed' command, as of release 0.1. You may
find in this document:
* Menu:
* Description:: Description
* Invoking:: Invoking GNU `ed'
* Line addressing:: Line addressing
* Regular expressions:: Regular expressions
* Commands:: Commands
* Limitations:: Limitations
* Diagnostics:: Diagnostics
File: ed.info, Node: Description, Next: Invoking, Prev: Top, Up: Top
Description
***********
`ed' is a line-oriented text editor. It is used to create, display,
modify and otherwise manipulate text files. `red' is a restricted
`ed': it can only edit files in the current directory and cannot
execute shell commands.
Related programs or routines are `vi (1)', `sed (1)', `regex (3)',
`bdes (1)' and `sh (1)'. Related documents are `USD:12-13' and:
B. W. Kernighan and P. J. Plauger: "Software Tools in Pascal",
Addison-Wesley, 1981.
If invoked with a FILE argument, then a copy of FILE is read into
the editor's buffer. Changes are made to this copy and not directly to
FILE itself. Upon quitting `ed', any changes not explicitly saved with
a `w' command are lost.
Editing is done in two distinct modes: "command" and "input". When
first invoked, `ed' is in command mode. In this mode commands are read
from the standard input and executed to manipulate the contents of the
editor buffer. A typical command might look like:
,s/OLD/NEW/g
which replaces all occurences of the string OLD with NEW.
When an input command, such as `a' (append), `i' (insert) or `c'
(change), is given, `ed' enters input mode. This is the primary means
of adding text to a file. In this mode, no commands are available;
instead, the standard input is written directly to the editor buffer.
The text up to and including a newline character defines a single line.
Input mode is terminated by entering a single period (`.') on a line.
All `ed' commands operate on whole lines or ranges of lines; e.g.,
the `d' command deletes lines; the `m' command moves lines, and so on.
It is possible to modify only a portion of a line by means of
replacement, as in the example above. However even here, the `s'
command is applied to whole lines at a time.
In general, `ed' commands consist of zero or more line addresses,
followed by a single character command and possibly additional
parameters; i.e., commands have the structure:
[ADDRESS [,ADDRESS]]COMMAND[PARAMETERS]
The ADDRESS(es) indicate the line or range of lines to be affected
by the command. If fewer addresses are given than the command accepts,
then default addresses are supplied.
File: ed.info, Node: Invoking, Next: Line addressing, Prev: Description, Up: Top
Invoking GNU `ed'
*****************
ed [-] [-Gs] [-p STRING] [FILE]
red [-] [-Gs] [-p STRING] [FILE]
Forces backwards compatibility. This affects the behavior of the
`ed' commands `G', `f', `l', `m', `t' and `!!'. If the default
behavior of these commands does not seem familiar, then try
invoking `ed' with this switch.
Suppresses diagnostics. This should be used if `ed''s standard
input is from a script.
`-p STRING'
Specifies a command prompt. This may be toggled on and off with
the `P' command.
FILE specifies the name of a file to read. If FILE is prefixed with
a bang (!), then it is interpreted as a shell command. In this case,
what is read is the standard output of FILE executed via `sh (1)'. To
read a file whose name begins with a bang, prefix the name with a
backslash (`\'). The default filename is set to FILE only if it is not
prefixed with a bang.
File: ed.info, Node: Line addressing, Next: Regular expressions, Prev: Invoking, Up: Top
Line addressing
***************
An address represents the number of a line in the buffer. `ed'
maintains a "current address" which is typically supplied to commands
as the default address when none is specified. When a file is first
read, the current address is set to the last line of the file. In
general, the current address is set to the last line affected by a
command.
A line address is constructed from one of the bases in the list
below, optionally followed by a numeric offset. The offset may include
any combination of digits, operators (i.e., `+', `-' and `^') and
whitespace. Addresses are read from left to right, and their values
are computed relative to the current address.
One exception to the rule that addresses represent line numbers is
the address `0' (zero). This means "before the first line," and is
legal wherever it makes sense.
An address range is two addresses separated either by a comma or
semi-colon. The value of the first address in a range cannot exceed the
value of the the second. If only one address is given in a range, then
the second address is set to the given address. If an N-tuple of
addresses is given where N > 2, then the corresponding range is
determined by the last two addresses in the N-tuple. If only one
address is expected, then the last address is used.
Each address in a comma-delimited range is interpreted relative to
the current address. In a semi-colon-delimited range, the first
address is used to set the current address, and the second address is
interpreted relative to the first.
The following address symbols are recognized.
The current line (address) in the buffer.
The last line in the buffer.
The Nth, line in the buffer where N is a number in the range `0,$'.
The previous line. This is equivalent to `-1' and may be repeated
with cumulative effect.
The Nth previous line, where N is a non-negative number.
The next line. This is equivalent to `+1' and may be repeated with
cumulative effect.
`WHITESPACE N'
The Nth next line, where N is a non-negative number. Whitespace
followed by a number N is interpreted as `+N'.
The first through last lines in the buffer. This is equivalent to
the address range `1,$'.
The current through last lines in the buffer. This is equivalent
to the address range `.,$'.
`/RE/'
The next line containing the regular expression RE. The search
wraps to the beginning of the buffer and continues down to the
current line, if necessary. `//' repeats the last search.
`?RE?'
The previous line containing the regular expression RE. The
search wraps to the end of the buffer and continues up to the
current line, if necessary. `??' repeats the last search.
`'LC'
The line previously marked by a `k' (mark) command, where LC is a
lower case letter.
File: ed.info, Node: Regular expressions, Next: Commands, Prev: Line addressing, Up: Top
Regular expressions
*******************
Regular expressions are patterns used in selecting text. For
example, the `ed' command
g/STRING/
prints all lines containing STRING. Regular expressions are also used
by the `s' command for selecting old text to be replaced with new.
In addition to a specifying string literals, regular expressions can
represent classes of strings. Strings thus represented are said to be
matched by the correspondi