1752 lines
61 KiB
HTML
1752 lines
61 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>ed</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="ed"></a> <a name="tag_04_42"></a><!-- ed -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_04_42_01"></a>NAME</h4>
|
|
|
|
<blockquote>ed - edit text</blockquote>
|
|
|
|
<h4><a name="tag_04_42_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>ed</tt> <b>[</b><tt>-p</tt> <i>string</i><b>][</b><tt>-s</tt><b>][</b><i>file</i><b>]</b></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>ed</i> utility is a line-oriented text editor that uses two modes: <i>command mode</i> and <i>input mode</i>. In command
|
|
mode the input characters shall be interpreted as commands, and in input mode they shall be interpreted as text. See the EXTENDED
|
|
DESCRIPTION section.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_04"></a>OPTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>ed</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p>
|
|
|
|
<p>The following options shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><b>-p </b> <i>string</i></dt>
|
|
|
|
<dd>Use <i>string</i> as the prompt string when in command mode. By default, there shall be no prompt string.</dd>
|
|
|
|
<dt><b>-s</b></dt>
|
|
|
|
<dd>Suppress the writing of byte counts by <b>e</b>, <b>E</b>, <b>r</b>, and <b>w</b> commands and of the <tt>'!'</tt> prompt after
|
|
a !<i>command</i>.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_05"></a>OPERANDS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following operand shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>file</i></dt>
|
|
|
|
<dd>If the <i>file</i> argument is given, <i>ed</i> shall simulate an <b>e</b> command on the file named by the pathname,
|
|
<i>file</i>, before accepting commands from the standard input. If the <i>file</i> operand is <tt>'-'</tt> , the results are
|
|
unspecified.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_06"></a>STDIN</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard input shall be a text file consisting of commands, as described in the EXTENDED DESCRIPTION section.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_07"></a>INPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>The input files shall be text files.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_08"></a>ENVIRONMENT VARIABLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The following environment variables shall affect the execution of <i>ed</i>:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>HOME</i></dt>
|
|
|
|
<dd>Determine the pathname of the user's home directory.</dd>
|
|
|
|
<dt><i>LANG</i></dt>
|
|
|
|
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
|
|
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
|
|
|
|
<dt><i>LC_ALL</i></dt>
|
|
|
|
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
|
|
|
|
<dt><i>LC_COLLATE</i></dt>
|
|
|
|
<dd><br>
|
|
Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements within regular
|
|
expressions.</dd>
|
|
|
|
<dt><i>LC_CTYPE</i></dt>
|
|
|
|
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
|
|
opposed to multi-byte characters in arguments and input files) and the behavior of character classes within regular
|
|
expressions.</dd>
|
|
|
|
<dt><i>LC_MESSAGES</i></dt>
|
|
|
|
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and
|
|
informative messages written to standard output.</dd>
|
|
|
|
<dt><i>NLSPATH</i></dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_09"></a>ASYNCHRONOUS EVENTS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>ed</i> utility shall take the standard action for all signals (see the ASYNCHRONOUS EVENTS section in <a href=
|
|
"xcu_chap01.html#tag_01_11"><i>Utility Description Defaults</i></a> ) with the following exceptions:</p>
|
|
|
|
<dl compact>
|
|
<dt>SIGINT</dt>
|
|
|
|
<dd>The <i>ed</i> utility shall interrupt its current activity, write the string <tt>"?\n"</tt> to standard output, and return to
|
|
command mode (see the EXTENDED DESCRIPTION section).</dd>
|
|
|
|
<dt>SIGHUP</dt>
|
|
|
|
<dd>If the buffer is not empty and has changed since the last write, the <i>ed</i> utility shall attempt to write a copy of the
|
|
buffer in a file. First, the file named <b>ed.hup</b> in the current directory shall be used; if that fails, the file named
|
|
<b>ed.hup</b> in the directory named by the <i>HOME</i> environment variable shall be used. In any case, the <i>ed</i> utility
|
|
shall exit without returning to command mode.</dd>
|
|
|
|
<dt>SIGQUIT</dt>
|
|
|
|
<dd>The <i>ed</i> utility shall ignore this event.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_10"></a>STDOUT</h4>
|
|
|
|
<blockquote>
|
|
<p>Various editing commands and the prompting feature (see <b>-p</b>) write to standard output, as described in the EXTENDED
|
|
DESCRIPTION section.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_11"></a>STDERR</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard error shall be used only for diagnostic messages.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_12"></a>OUTPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>The output files shall be text files whose formats are dependent on the editing commands given.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_13"></a>EXTENDED DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>ed</i> utility shall operate on a copy of the file it is editing; changes made to the copy shall have no effect on the
|
|
file until a <b>w</b> (write) command is given. The copy of the text is called the <i>buffer</i>.</p>
|
|
|
|
<p>Commands to <i>ed</i> have a simple and regular structure: zero, one, or two <i>addresses</i> followed by a single-character
|
|
<i>command</i>, 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 very often can be omitted. If the <b>-p</b> option is
|
|
specified, the prompt string shall be written to standard output before each command is read.</p>
|
|
|
|
<p>In general, only one command can appear on a line. Certain commands allow text to be input. This text is placed in the
|
|
appropriate place in the buffer. While <i>ed</i> is accepting text, it is said to be in <i>input mode</i>. In this mode, no
|
|
commands shall be recognized; all input is merely collected. Input mode is terminated by entering a line consisting of two
|
|
characters: a period ( <tt>'.'</tt> ) followed by a <newline>. This line is not considered part of the input text.</p>
|
|
|
|
<h5><a name="tag_04_42_13_01"></a>Regular Expressions in ed</h5>
|
|
|
|
<p>The <i>ed</i> utility shall support basic regular expressions, as described in the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap09.html#tag_09_03">Section 9.3, Basic Regular Expressions</a>. Since
|
|
regular expressions in <i>ed</i> are always matched against single lines (excluding the terminating <newline>s), never
|
|
against any larger section of text, there is no way for a regular expression to match a <newline>.</p>
|
|
|
|
<p>A null RE shall be equivalent to the last RE encountered.</p>
|
|
|
|
<p>Regular expressions are used in addresses to specify lines, and in some commands (for example, the <b>s</b> substitute command)
|
|
to specify portions of a line to be substituted.</p>
|
|
|
|
<h5><a name="tag_04_42_13_02"></a>Addresses in ed</h5>
|
|
|
|
<p>Addressing in <i>ed</i> relates to the current line. Generally, the current line is the last line affected by a command. The
|
|
current line number is the address of the current line. If the edit buffer is not empty, the initial value for the current line
|
|
shall be the last line in the edit buffer; otherwise, zero.</p>
|
|
|
|
<p>Addresses shall be constructed as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>The period character ( <tt>'.'</tt> ) shall address the current line.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The dollar sign character ( <tt>'$'</tt> ) shall address the last line of the edit buffer.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The positive decimal number <i>n</i> shall address the <i>n</i>th line of the edit buffer.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The apostrophe-x character pair ( <tt>"'x"</tt> ) shall address the line marked with the mark name character <i>x</i>, which
|
|
shall be a lowercase letter from the portable character set. It shall be an error if the character has not been set to mark a line
|
|
or if the line that was marked is not currently present in the edit buffer.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>A BRE enclosed by slash characters ( <tt>'/'</tt> ) shall address the first line found by searching forwards from the line
|
|
following the current line toward the end of the edit buffer and stopping at the first line for which the line excluding the
|
|
terminating <newline> matches the BRE. The BRE consisting of a null BRE delimited by a pair of slash characters shall address
|
|
the next line for which the line excluding the terminating <newline> matches the last BRE encountered. In addition, the
|
|
second slash can be omitted at the end of a command line. Within the BRE, a backslash-slash pair ( <tt>"\/"</tt> ) shall represent
|
|
a literal slash instead of the BRE delimiter. If necessary, the search shall wrap around to the beginning of the buffer and
|
|
continue up to and including the current line, so that the entire buffer is searched.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>A BRE enclosed by question-mark characters ( <tt>'?'</tt> ) shall address the first line found by searching backwards from the
|
|
line preceding the current line toward the beginning of the edit buffer and stopping at the first line for which the line excluding
|
|
the terminating <newline> matches the BRE. The BRE consisting of a null BRE delimited by a pair of question-mark characters (
|
|
<tt>"??"</tt> ) shall address the previous line for which the line excluding the terminating <newline> matches the last BRE
|
|
encountered. In addition, the second question-mark can be omitted at the end of a command line. Within the BRE, a
|
|
backslash-question-mark pair ( <tt>"\?"</tt> ) shall represent a literal question mark instead of the BRE delimiter. If necessary,
|
|
the search shall wrap around to the end of the buffer and continue up to and including the current line, so that the entire buffer
|
|
is searched.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>A plus-sign ( <tt>'+'</tt> ) or hyphen character ( <tt>'-'</tt> ) followed by a decimal number shall address the current line
|
|
plus or minus the number. A plus-sign or hyphen character not followed by a decimal number shall address the current line plus or
|
|
minus 1.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Addresses can be followed by zero or more address offsets, optionally <blank>-separated. Address offsets are constructed
|
|
as follows:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>A plus-sign or hyphen character followed by a decimal number shall add or subtract, respectively, the indicated number of lines
|
|
to or from the address. A plus-sign or hyphen character not followed by a decimal number shall add or subtract 1 to or from the
|
|
address.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>A decimal number shall add the indicated number of lines to the address.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>It shall not be an error for an intermediate address value to be less than zero or greater than the last line in the edit
|
|
buffer. It shall be an error for the final address value to be less than zero or greater than the last line in the edit buffer. It
|
|
shall be an error if a search for a BRE fails to find a matching line.</p>
|
|
|
|
<p>Commands accept zero, one, or two addresses. If more than the required number of addresses are provided to a command that
|
|
requires zero addresses, it shall be an error. Otherwise, if more than the required number of addresses are provided to a command,
|
|
the addresses specified first shall be evaluated and then discarded until the maximum number of valid addresses remain, for the
|
|
specified command.</p>
|
|
|
|
<p>Addresses shall be separated from each other by a comma ( <tt>','</tt> ) or semicolon character ( <tt>';'</tt> ). In the case of
|
|
a semicolon separator, the current line ( <tt>'.'</tt> ) shall be set to the first address, and only then will the second address
|
|
be calculated. This feature can be used to determine the starting line for forwards and backwards searches; see rules 5. and 6.</p>
|
|
|
|
<p>Addresses can be omitted on either side of the comma or semicolon separator, in which case the resulting address pairs shall be
|
|
as follows:</p>
|
|
|
|
<center>
|
|
<table border="1" cellpadding="3" align="center">
|
|
<tr valign="top">
|
|
<th align="center">
|
|
<p class="tent"><b>Specified</b></p>
|
|
</th>
|
|
<th align="center">
|
|
<p class="tent"><b>Resulting</b></p>
|
|
</th>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">,</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">1 , $</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">, addr</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">1 , addr</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">addr ,</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">addr , addr</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">;</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">. ; $</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">; addr</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">. ; addr</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">addr ;</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">addr ; addr</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
|
|
<p>Any <blank>s included between addresses, address separators, or address offsets shall be ignored.</p>
|
|
|
|
<h5><a name="tag_04_42_13_03"></a>Commands in ed</h5>
|
|
|
|
<p>In the following list of <i>ed</i> commands, the default addresses are shown in parentheses. The number of addresses shown in
|
|
the default shall be the number expected by the command. The parentheses are not part of the address; they show that the given
|
|
addresses are the default.</p>
|
|
|
|
<p>It is generally invalid for more than one command to appear on a line. However, any command (except <b>e</b>, <b>E</b>,
|
|
<b>f</b>, <b>q</b>, <b>Q</b>, <b>r</b>, <b>w</b>, and <b>!</b>) can be suffixed by the letter <b>l</b>, <b>n</b>, or <b>p</b>; in
|
|
which case, except for the <b>l</b>, <b>n</b>, and <b>p</b> commands, the command shall be executed and then the new current line
|
|
shall be written as described below under the <b>l</b>, <b>n</b>, and <b>p</b> commands. When an <b>l</b>, <b>n</b>, or <b>p</b>
|
|
suffix is used with an <b>l</b>, <b>n</b>, or <b>p</b> command, the command shall write to standard output as described below, but
|
|
it is unspecified whether the suffix writes the current line again in the requested format or whether the suffix has no effect. For
|
|
example, the <b>pl</b> command (base <b>p</b> command with an <b>l</b> suffix) shall either write just the current line or write it
|
|
twice-once as specified for <b>p</b> and once as specified for <b>l</b>. Also, the <b>g</b>, <b>G</b>, <b>v</b>, and <b>V</b>
|
|
commands shall take a command as a parameter.</p>
|
|
|
|
<p>Each address component can be preceded by zero or more <blank>s. The command letter can be preceded by zero or more
|
|
<blank>s. If a suffix letter ( <b>l</b>, <b>n</b>, or <b>p</b>) is given, the application shall ensure that it immediately
|
|
follows the command.</p>
|
|
|
|
<p>The <b>e</b>, <b>E</b>, <b>f</b>, <b>r</b>, and <b>w</b> commands shall take an optional <i>file</i> parameter, separated from
|
|
the command letter by one or more <blank>s.</p>
|
|
|
|
<p>If changes have been made in the buffer since the last <b>w</b> command that wrote the entire buffer, <i>ed</i> shall warn the
|
|
user if an attempt is made to destroy the editor buffer via the <b>e</b> or <b>q</b> commands. The <i>ed</i> utility shall write
|
|
the string:</p>
|
|
|
|
<pre>
|
|
<tt>"?\n"
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>(followed by an explanatory message if <i>help mode</i> has been enabled via the <b>H</b> command) to standard output and shall
|
|
continue in command mode with the current line number unchanged. If the <b>e</b> or <b>q</b> command is repeated with no
|
|
intervening command, it shall take effect.</p>
|
|
|
|
<p>If a terminal disconnect is detected:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>If the buffer is not empty and has changed since the last write, the <i>ed</i> utility shall attempt to write a copy of the
|
|
buffer to a file named <b>ed.hup</b> in the current directory. If this write fails, <i>ed</i> shall attempt to write a copy of the
|
|
buffer to a filename <b>ed.hup</b> in the directory named by the <i>HOME</i> environment variable. If both these attempts fail,
|
|
<i>ed</i> shall exit without saving the buffer.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The <i>ed</i> utility shall not write the file to the currently remembered pathname or return to command mode, and shall
|
|
terminate with a non-zero exit status.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>If an end-of-file is detected on standard input:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>If the <i>ed</i> utility is in input mode, <i>ed</i> shall terminate input mode and return to command mode. It is unspecified if
|
|
any partially entered lines (that is, input text without a terminating <newline>) are discarded from the input text.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the <i>ed</i> utility is in command mode, it shall act as if a <b>q</b> command had been entered.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>If the closing delimiter of an RE or of a replacement string (for example, <tt>'/'</tt> ) in a <b>g</b>, <b>G</b>, <b>s</b>,
|
|
<b>v</b>, or <b>V</b> command would be the last character before a <newline>, that delimiter can be omitted, in which case
|
|
the addressed line shall be written. For example, the following pairs of commands are equivalent:</p>
|
|
|
|
<pre>
|
|
<tt>s/s1/s2 s/s1/s2/p
|
|
g/s1 g/s1/p
|
|
?s1 ?s1?
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If an invalid command is entered, <i>ed</i> shall write the string:</p>
|
|
|
|
<pre>
|
|
<tt>"?\n"
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>(followed by an explanatory message if <i>help mode</i> has been enabled via the <b>H</b> command) to standard output and shall
|
|
continue in command mode with the current line number unchanged.</p>
|
|
|
|
<h5><a name="tag_04_42_13_04"></a>Append Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.)a
|
|
<</tt><i>text</i><tt>>
|
|
.
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>a</b> command shall read the given text and append it after the addressed line; the current line number shall become the
|
|
address of the last inserted line or, if there were none, the addressed line. Address 0 shall be valid for this command; it shall
|
|
cause the appended text to be placed at the beginning of the buffer.</p>
|
|
|
|
<h5><a name="tag_04_42_13_05"></a>Change Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.,.)c
|
|
<</tt><i>text</i><tt>>
|
|
.
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>c</b> command shall delete the addressed lines, then accept input text that replaces these lines; the current line shall
|
|
be set to the address of the last line input; or, if there were none, at the line after the last line deleted; if the lines deleted
|
|
were originally at the end of the buffer, the current line number shall be set to the address of the new last line; if no lines
|
|
remain in the buffer, the current line number shall be set to zero. Address 0 shall be valid for this command; it shall be
|
|
interpreted as if address 1 were specified.</p>
|
|
|
|
<h5><a name="tag_04_42_13_06"></a>Delete Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.,.)d
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>d</b> command shall delete the addressed lines from the buffer. The address of the line after the last line deleted shall
|
|
become the current line number; if the lines deleted were originally at the end of the buffer, the current line number shall be set
|
|
to the address of the new last line; if no lines remain in the buffer, the current line number shall be set to zero.</p>
|
|
|
|
<h5><a name="tag_04_42_13_07"></a>Edit Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>e</tt> <b>[</b><i>file</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>e</b> command shall delete the entire contents of the buffer and then read in the file named by the pathname <i>file</i>.
|
|
The current line number shall be set to the address of the last line of the buffer. If no pathname is given, the currently
|
|
remembered pathname, if any, shall be used (see the <b>f</b> command). The number of bytes read shall be written to standard
|
|
output, unless the <b>-s</b> option was specified, in the following format:</p>
|
|
|
|
<pre>
|
|
<tt>"%d\n", <</tt><i>number of bytes read</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The name <i>file</i> shall be remembered for possible use as a default pathname in subsequent <b>e</b>, <b>E</b>, <b>r</b>, and
|
|
<b>w</b> commands. If <i>file</i> is replaced by <tt>'!'</tt> , the rest of the line shall be taken to be a shell command line
|
|
whose output is to be read. Such a shell command line shall not be remembered as the current <i>file</i>. All marks shall be
|
|
discarded upon the completion of a successful <b>e</b> command. If the buffer has changed since the last time the entire buffer was
|
|
written, the user shall be warned, as described previously.</p>
|
|
|
|
<h5><a name="tag_04_42_13_08"></a>Edit Without Checking Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>E</tt> <b>[</b><i>file</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>E</b> command shall possess all properties and restrictions of the <b>e</b> command except that the editor shall not
|
|
check to see whether any changes have been made to the buffer since the last <b>w</b> command.</p>
|
|
|
|
<h5><a name="tag_04_42_13_09"></a>Filename Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>f</tt> <b>[</b><i>file</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If <i>file</i> is given, the <b>f</b> command shall change the currently remembered pathname to <i>file</i>; whether the name is
|
|
changed or not, it shall then write the (possibly new) currently remembered pathname to the standard output in the following
|
|
format:</p>
|
|
|
|
<pre>
|
|
<tt>"%s\n", <</tt><i>pathname</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The current line number shall be unchanged.</p>
|
|
|
|
<h5><a name="tag_04_42_13_10"></a>Global Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(1,$)g/</tt><i>RE</i><tt>/</tt><i>command list</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>In the <b>g</b> command, the first step shall be to mark every line for which the line excluding the terminating <newline>
|
|
matches the given RE. Then, going sequentially from the beginning of the file to the end of the file, the given <i>command list</i>
|
|
shall be executed for each marked line, with the current line number set to the address of that line. Any line modified by the
|
|
<i>command list</i> shall be unmarked. When the <b>g</b> command completes, the current line number shall have the value assigned
|
|
by the last command in the <i>command list</i>. If there were no matching lines, the current line number shall not be changed. A
|
|
single command or the first of a list of commands shall appear on the same line as the global command. All lines of a multi-line
|
|
list except the last line shall be ended with a backslash preceding the terminating <newline>; the <b>a</b>, <b>i</b>, and
|
|
<b>c</b> commands and associated input are permitted. The <tt>'.'</tt> terminating input mode can be omitted if it would be the
|
|
last line of the <i>command list</i>. An empty <i>command list</i> shall be equivalent to the <b>p</b> command. The use of the
|
|
<b>g</b>, <b>G</b>, <b>v</b>, <b>V</b>, and <b>!</b> commands in the <i>command list</i> produces undefined results. Any character
|
|
other than <space> or <newline> can be used instead of a slash to delimit the RE. Within the RE, the RE delimiter
|
|
itself can be used as a literal character if it is preceded by a backslash.</p>
|
|
|
|
<h5><a name="tag_04_42_13_11"></a>Interactive Global Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(1,$)G/</tt><i>RE</i><tt>/
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>In the <b>G</b> command, the first step shall be to mark every line for which the line excluding the terminating <newline>
|
|
matches the given RE. Then, for every such line, that line shall be written, the current line number shall be set to the address of
|
|
that line, and any one command (other than one of the <b>a</b>, <b>c</b>, <b>i</b>, <b>g</b>, <b>G</b>, <b>v</b>, and <b>V</b>
|
|
commands) shall be read and executed. A <newline> shall act as a null command (causing no action to be taken on the current
|
|
line); an <tt>'&'</tt> shall cause the re-execution of the most recent non-null command executed within the current invocation
|
|
of <b>G</b>. Note that the commands input as part of the execution of the <b>G</b> command can address and affect any lines in the
|
|
buffer. The final value of the current line number shall be the value set by the last command successfully executed. (Note that the
|
|
last command successfully executed shall be the <b>G</b> command itself if a command fails or the null command is specified.) If
|
|
there were no matching lines, the current line number shall not be changed. The <b>G</b> command can be terminated by a SIGINT
|
|
signal. Any character other than <space> or <newline> can be used instead of a slash to delimit the RE and the
|
|
replacement. Within the RE, the RE delimiter itself can be used as a literal character if it is preceded by a backslash.</p>
|
|
|
|
<h5><a name="tag_04_42_13_12"></a>Help Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>h
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>h</b> command shall write a short message to standard output that explains the reason for the most recent <tt>'?'</tt>
|
|
notification. The current line number shall be unchanged.</p>
|
|
|
|
<h5><a name="tag_04_42_13_13"></a>Help-Mode Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>H
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>H</b> command shall cause <i>ed</i> to enter a mode in which help messages (see the <b>h</b> command) shall be written to
|
|
standard output for all subsequent <tt>'?'</tt> notifications. The <b>H</b> command alternately shall turn this mode on and off; it
|
|
is initially off. If the help-mode is being turned on, the <b>H</b> command also explains the previous <tt>'?'</tt> notification,
|
|
if there was one. The current line number shall be unchanged.</p>
|
|
|
|
<h5><a name="tag_04_42_13_14"></a>Insert Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.)i
|
|
<</tt><i>text</i><tt>>
|
|
.
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>i</b> command shall insert the given text before the addressed line; the current line is set to the last inserted line
|
|
or, if there was none, to the addressed line. This command differs from the <b>a</b> command only in the placement of the input
|
|
text. Address 0 shall be valid for this command; it shall be interpreted as if address 1 were specified.</p>
|
|
|
|
<h5><a name="tag_04_42_13_15"></a>Join Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.,.+1)j
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>j</b> command shall join contiguous lines by removing the appropriate <newline>s. If exactly one address is given,
|
|
this command shall do nothing. If lines are joined, the current line number shall be set to the address of the joined line;
|
|
otherwise, the current line number shall be unchanged.</p>
|
|
|
|
<h5><a name="tag_04_42_13_16"></a>Mark Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.)k</tt><i>x</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>k</b> command shall mark the addressed line with name <i>x</i>, which the application shall ensure is a lowercase letter
|
|
from the portable character set. The address <tt>"'x"</tt> shall then refer to this line; the current line number shall be
|
|
unchanged.</p>
|
|
|
|
<h5><a name="tag_04_42_13_17"></a>List Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.,.)l
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>l</b> command shall write to standard output the addressed lines in a visually unambiguous form. The characters listed in
|
|
the Base Definitions volume of IEEE Std 1003.1-2001, Table 5-1, Escape Sequences and Associated Actions ( <tt>'\\'</tt> ,
|
|
<tt>'\a'</tt> , <tt>'\b'</tt> , <tt>'\f'</tt> , <tt>'\r'</tt> , <tt>'\t'</tt> , <tt>'\v'</tt> ) shall be written as the
|
|
corresponding escape sequence; the <tt>'\n'</tt> in that table is not applicable. Non-printable characters not in the table shall
|
|
be written as one three-digit octal number (with a preceding backslash character) for each byte in the character (most significant
|
|
byte first). If the size of a byte on the system is greater than nine bits, the format used for non-printable characters is
|
|
implementation-defined.</p>
|
|
|
|
<p>Long lines shall be folded, with the point of folding indicated by <newline> preceded by a backslash; the length at which
|
|
folding occurs is unspecified, but should be appropriate for the output device. The end of each line shall be marked with a
|
|
<tt>'$'</tt> , and <tt>'$'</tt> characters within the text shall be written with a preceding backslash. An <b>l</b> command can be
|
|
appended to any other command other than <b>e</b>, <b>E</b>, <b>f</b>, <b>q</b>, <b>Q</b>, <b>r</b>, <b>w</b>, or <b>!</b>. The
|
|
current line number shall be set to the address of the last line written.</p>
|
|
|
|
<h5><a name="tag_04_42_13_18"></a>Move Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.,.)m</tt><i>address</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>m</b> command shall reposition the addressed lines after the line addressed by <i>address</i>. Address 0 shall be valid
|
|
for <i>address</i> and cause the addressed lines to be moved to the beginning of the buffer. It shall be an error if address
|
|
<i>address</i> falls within the range of moved lines. The current line number shall be set to the address of the last line
|
|
moved.</p>
|
|
|
|
<h5><a name="tag_04_42_13_19"></a>Number Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.,.)n
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>n</b> command shall write to standard output the addressed lines, preceding each line by its line number and a
|
|
<tab>; the current line number shall be set to the address of the last line written. The <b>n</b> command can be appended to
|
|
any command other than <b>e</b>, <b>E</b>, <b>f</b>, <b>q</b>, <b>Q</b>, <b>r</b>, <b>w</b>, or <b>!</b>.</p>
|
|
|
|
<h5><a name="tag_04_42_13_20"></a>Print Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.,.)p
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>p</b> command shall write to standard output the addressed lines; the current line number shall be set to the address of
|
|
the last line written. The <b>p</b> command can be appended to any command other than <b>e</b>, <b>E</b>, <b>f</b>, <b>q</b>,
|
|
<b>Q</b>, <b>r</b>, <b>w</b>, or <b>!</b>.</p>
|
|
|
|
<h5><a name="tag_04_42_13_21"></a>Prompt Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>P
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>P</b> command shall cause <i>ed</i> to prompt with an asterisk ( <tt>'*'</tt> ) (or <i>string</i>, if <b>-p</b> is
|
|
specified) for all subsequent commands. The <b>P</b> command alternatively shall turn this mode on and off; it shall be initially
|
|
on if the <b>-p</b> option is specified; otherwise, off. The current line number shall be unchanged.</p>
|
|
|
|
<h5><a name="tag_04_42_13_22"></a>Quit Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>q
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>q</b> command shall cause <i>ed</i> to exit. If the buffer has changed since the last time the entire buffer was written,
|
|
the user shall be warned, as described previously.</p>
|
|
|
|
<h5><a name="tag_04_42_13_23"></a>Quit Without Checking Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>Q
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>Q</b> command shall cause <i>ed</i> to exit without checking whether changes have been made in the buffer since the last
|
|
<b>w</b> command.</p>
|
|
|
|
<h5><a name="tag_04_42_13_24"></a>Read Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>($)r</tt> <b>[</b><i>file</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>r</b> command shall read in the file named by the pathname <i>file</i> and append it after the addressed line. If no
|
|
<i>file</i> argument is given, the currently remembered pathname, if any, shall be used (see the <b>e</b> and <b>f</b> commands).
|
|
The currently remembered pathname shall not be changed unless there is no remembered pathname. Address 0 shall be valid for
|
|
<b>r</b> and shall cause the file to be read at the beginning of the buffer. If the read is successful, and <b>-s</b> was not
|
|
specified, the number of bytes read shall be written to standard output in the following format:</p>
|
|
|
|
<pre>
|
|
<tt>"%d\n", <</tt><i>number of bytes read</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The current line number shall be set to the address of the last line read in. If <i>file</i> is replaced by <tt>'!'</tt> , the
|
|
rest of the line shall be taken to be a shell command line whose output is to be read. Such a shell command line shall not be
|
|
remembered as the current pathname.</p>
|
|
|
|
<h5><a name="tag_04_42_13_25"></a>Substitute Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.,.)s/</tt><i>RE</i><tt>/</tt><i>replacement</i><tt>/</tt><i>flags</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>s</b> command shall search each addressed line for an occurrence of the specified RE and replace either the first or all
|
|
(non-overlapped) matched strings with the <i>replacement</i>; see the following description of the <b>g</b> suffix. It is an error
|
|
if the substitution fails on every addressed line. Any character other than <space> or <newline> can be used instead of
|
|
a slash to delimit the RE and the replacement. Within the RE, the RE delimiter itself can be used as a literal character if it is
|
|
preceded by a backslash. The current line shall be set to the address of the last line on which a substitution occurred.</p>
|
|
|
|
<p>An ampersand ( <tt>'&'</tt> ) appearing in the <i>replacement</i> shall be replaced by the string matching the RE on the
|
|
current line. The special meaning of <tt>'&'</tt> in this context can be suppressed by preceding it by backslash. As a more
|
|
general feature, the characters <tt>'\n'</tt> , where <i>n</i> is a digit, shall be replaced by the text matched by the
|
|
corresponding back-reference expression. When the character <tt>'%'</tt> is the only character in the <i>replacement</i>, the
|
|
<i>replacement</i> used in the most recent substitute command shall be used as the <i>replacement</i> in the current substitute
|
|
command; if there was no previous substitute command, the use of <tt>'%'</tt> in this manner shall be an error. The <tt>'%'</tt>
|
|
shall lose its special meaning when it is in a replacement string of more than one character or is preceded by a backslash. For
|
|
each backslash ( <tt>'\'</tt> ) encountered in scanning <i>replacement</i> from beginning to end, the following character shall
|
|
lose its special meaning (if any). It is unspecified what special meaning is given to any character other than <tt>'&'</tt> ,
|
|
<tt>'\'</tt> , <tt>'%'</tt> , or digits.</p>
|
|
|
|
<p>A line can be split by substituting a <newline> into it. The application shall ensure it escapes the <newline> in
|
|
the <i>replacement</i> by preceding it by backslash. Such substitution cannot be done as part of a <b>g</b> or <b>v</b> <i>command
|
|
list</i>. The current line number shall be set to the address of the last line on which a substitution is performed. If no
|
|
substitution is performed, the current line number shall be unchanged. If a line is split, a substitution shall be considered to
|
|
have been performed on each of the new lines for the purpose of determining the new current line number. A substitution shall be
|
|
considered to have been performed even if the replacement string is identical to the string that it replaces.</p>
|
|
|
|
<p>The application shall ensure that the value of <i>flags</i> is zero or more of:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>count</i></dt>
|
|
|
|
<dd>Substitute for the <i>count</i>th occurrence only of the RE found on each addressed line.</dd>
|
|
|
|
<dt><b>g</b></dt>
|
|
|
|
<dd>Globally substitute for all non-overlapping instances of the RE rather than just the first one. If both <b>g</b> and
|
|
<i>count</i> are specified, the results are unspecified.</dd>
|
|
|
|
<dt><b>l</b></dt>
|
|
|
|
<dd>Write to standard output the final line in which a substitution was made. The line shall be written in the format specified for
|
|
the <b>l</b> command.</dd>
|
|
|
|
<dt><b>n</b></dt>
|
|
|
|
<dd>Write to standard output the final line in which a substitution was made. The line shall be written in the format specified for
|
|
the <b>n</b> command.</dd>
|
|
|
|
<dt><b>p</b></dt>
|
|
|
|
<dd>Write to standard output the final line in which a substitution was made. The line shall be written in the format specified for
|
|
the <b>p</b> command.</dd>
|
|
</dl>
|
|
|
|
<h5><a name="tag_04_42_13_26"></a>Copy Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.,.)t</tt><i>address</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>t</b> command shall be equivalent to the <b>m</b> command, except that a copy of the addressed lines shall be placed
|
|
after address <i>address</i> (which can be 0); the current line number shall be set to the address of the last line added.</p>
|
|
|
|
<h5><a name="tag_04_42_13_27"></a>Undo Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>u
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>u</b> command shall nullify the effect of the most recent command that modified anything in the buffer, namely the most
|
|
recent <b>a</b>, <b>c</b>, <b>d</b>, <b>g</b>, <b>i</b>, <b>j</b>, <b>m</b>, <b>r</b>, <b>s</b>, <b>t</b>, <b>u</b>, <b>v</b>,
|
|
<b>G</b>, or <b>V</b> command. All changes made to the buffer by a <b>g</b>, <b>G</b>, <b>v</b>, or <b>V</b> global command shall
|
|
be undone as a single change; if no changes were made by the global command (such as with <b>g</b>/RE/ <b>p</b>), the <b>u</b>
|
|
command shall have no effect. The current line number shall be set to the value it had immediately before the command being undone
|
|
started.</p>
|
|
|
|
<h5><a name="tag_04_42_13_28"></a>Global Non-Matched Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(1,$)v/</tt><i>RE</i><tt>/</tt><i>command list</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>This command shall be equivalent to the global command <b>g</b> except that the lines that are marked during the first step
|
|
shall be those for which the line excluding the terminating <newline> does not match the RE.</p>
|
|
|
|
<h5><a name="tag_04_42_13_29"></a>Interactive Global Not-Matched Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(1,$)V/</tt><i>RE</i><tt>/
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>This command shall be equivalent to the interactive global command <b>G</b> except that the lines that are marked during the
|
|
first step shall be those for which the line excluding the terminating <newline> does not match the RE.</p>
|
|
|
|
<h5><a name="tag_04_42_13_30"></a>Write Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(1,$)w</tt> <b>[</b><i>file</i><b>]
|
|
</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <b>w</b> command shall write the addressed lines into the file named by the pathname <i>file</i>. The command shall create
|
|
the file, if it does not exist, or shall replace the contents of the existing file. The currently remembered pathname shall not be
|
|
changed unless there is no remembered pathname. If no pathname is given, the currently remembered pathname, if any, shall be used
|
|
(see the <b>e</b> and <b>f</b> commands); the current line number shall be unchanged. If the command is successful, the number of
|
|
bytes written shall be written to standard output, unless the <b>-s</b> option was specified, in the following format:</p>
|
|
|
|
<pre>
|
|
<tt>"%d\n", <</tt><i>number of bytes written</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If <i>file</i> begins with <tt>'!'</tt> , the rest of the line shall be taken to be a shell command line whose standard input
|
|
shall be the addressed lines. Such a shell command line shall not be remembered as the current pathname. This usage of the write
|
|
command with <tt>'!'</tt> shall not be considered as a "last <b>w</b> command that wrote the entire buffer", as described
|
|
previously; thus, this alone shall not prevent the warning to the user if an attempt is made to destroy the editor buffer via the
|
|
<b>e</b> or <b>q</b> commands.</p>
|
|
|
|
<h5><a name="tag_04_42_13_31"></a>Line Number Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>($)=
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The line number of the addressed line shall be written to standard output in the following format:</p>
|
|
|
|
<pre>
|
|
<tt>"%d\n", <</tt><i>line number</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The current line number shall be unchanged by this command.</p>
|
|
|
|
<h5><a name="tag_04_42_13_32"></a>Shell Escape Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>!</tt><i>command</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The remainder of the line after the <tt>'!'</tt> shall be sent to the command interpreter to be interpreted as a shell command
|
|
line. Within the text of that shell command line, the unescaped character <tt>'%'</tt> shall be replaced with the remembered
|
|
pathname; if a <tt>'!'</tt> appears as the first character of the command, it shall be replaced with the text of the previous shell
|
|
command executed via <tt>'!'</tt> . Thus, <tt>"!!"</tt> shall repeat the previous !<i>command</i>. If any replacements of
|
|
<tt>'%'</tt> or <tt>'!'</tt> are performed, the modified line shall be written to the standard output before <i>command</i> is
|
|
executed. The <b>!</b> command shall write:</p>
|
|
|
|
<pre>
|
|
<tt>"!\n"
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>to standard output upon completion, unless the <b>-s</b> option is specified. The current line number shall be unchanged.</p>
|
|
|
|
<h5><a name="tag_04_42_13_33"></a>Null Command</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>(.+1)
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>An address alone on a line shall cause the addressed line to be written. A <newline> alone shall be equivalent to
|
|
<tt>"+1p"</tt> . The current line number shall be set to the address of the written line.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_14"></a>EXIT STATUS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following exit values shall be returned:</p>
|
|
|
|
<dl compact>
|
|
<dt> 0</dt>
|
|
|
|
<dd>Successful completion without any file or command errors.</dd>
|
|
|
|
<dt>>0</dt>
|
|
|
|
<dd>An error occurred.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_15"></a>CONSEQUENCES OF ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>When an error in the input script is encountered, or when an error is detected that is a consequence of the data (not) present
|
|
in the file or due to an external condition such as a read or write error:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>If the standard input is a terminal device file, all input shall be flushed, and a new command read.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the standard input is a regular file, <i>ed</i> shall terminate with a non-zero exit status.</p>
|
|
</li>
|
|
</ul>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_04_42_16"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>Because of the extremely terse nature of the default error messages, the prudent script writer begins the <i>ed</i> input
|
|
commands with an <b>H</b> command, so that if any errors do occur at least some clue as to the cause is made available.</p>
|
|
|
|
<p>In previous versions, an obsolescent <b>-</b> option was described. This is no longer specified. Applications should use the
|
|
<b>-s</b> option. Using <b>-</b> as a <i>file</i> operand now produces unspecified results. This allows implementations to continue
|
|
to support the former required behavior.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_17"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_18"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>The initial description of this utility was adapted from the SVID. It contains some features not found in Version 7 or
|
|
BSD-derived systems. Some of the differences between the POSIX and BSD <i>ed</i> utilities include, but need not be limited to:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>The BSD <b>-</b> option does not suppress the <tt>'!'</tt> prompt after a <b>!</b> command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>BSD does not support the special meanings of the <tt>'%'</tt> and <tt>'!'</tt> characters within a <b>!</b> command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>BSD does not support the <i>addresses</i> <tt>';'</tt> and <tt>','</tt> .</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>BSD allows the command/suffix pairs <b>pp</b>, <b>ll</b>, and so on, which are unspecified in this volume of
|
|
IEEE Std 1003.1-2001.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>BSD does not support the <tt>'!'</tt> character part of the <b>e</b>, <b>r</b>, or <b>w</b> commands.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>A failed <b>g</b> command in BSD sets the line number to the last line searched if there are no matches.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>BSD does not default the <i>command list</i> to the <b>p</b> command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>BSD does not support the <b>G</b>, <b>h</b>, <b>H</b>, <b>n</b>, or <b>V</b> commands.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>On BSD, if there is no inserted text, the insert command changes the current line to the referenced line -1; that is, the line
|
|
before the specified line.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>On BSD, the <a href="../utilities/join.html"><i>join</i></a> command with only a single address changes the current line to that
|
|
address.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>BSD does not support the <b>P</b> command; moreover, in BSD it is synonymous with the <b>p</b> command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>BSD does not support the <i>undo</i> of the commands <b>j</b>, <b>m</b>, <b>r</b>, <b>s</b>, or <b>t</b>.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The Version 7 <i>ed</i> command <b>W</b>, and the BSD <i>ed</i> commands <b>W</b>, <b>wq</b>, and <b>z</b> are not present in
|
|
this volume of IEEE Std 1003.1-2001.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>The <b>-s</b> option was added to allow the functionality of the now withdrawn <b>-</b> option in a manner compatible with the
|
|
Utility Syntax Guidelines.</p>
|
|
|
|
<p>In early proposals there was a limit, {ED_FILE_MAX}, that described the historical limitations of some <i>ed</i> utilities in
|
|
their handling of large files; some of these have had problems with files larger than 100000 bytes. It was this limitation that
|
|
prompted much of the desire to include a <a href="../utilities/split.html"><i>split</i></a> command in this volume of
|
|
IEEE Std 1003.1-2001. Since this limit was removed, this volume of IEEE Std 1003.1-2001 requires that
|
|
implementations document the file size limits imposed by <i>ed</i> in the conformance document. The limit {ED_LINE_MAX} was also
|
|
removed; therefore, the global limit {LINE_MAX} is used for input and output lines.</p>
|
|
|
|
<p>The manner in which the <b>l</b> command writes non-printable characters was changed to avoid the historical
|
|
backspace-overstrike method. On video display terminals, the overstrike is ambiguous because most terminals simply replace
|
|
overstruck characters, making the <b>l</b> format not useful for its intended purpose of unambiguously understanding the content of
|
|
the line. The historical backslash escapes were also ambiguous. (The string <tt>"a\0011"</tt> could represent a line containing
|
|
those six characters or a line containing the three characters <tt>'a'</tt> , a byte with a binary value of 1, and a 1.) In the
|
|
format required here, a backslash appearing in the line is written as <tt>"\\"</tt> so that the output is truly unambiguous. The
|
|
method of marking the ends of lines was adopted from the <a href="../utilities/ex.html"><i>ex</i></a> editor and is required for
|
|
any line ending in <space>s; the <tt>'$'</tt> is placed on all lines so that a real <tt>'$'</tt> at the end of a line cannot
|
|
be misinterpreted.</p>
|
|
|
|
<p>Systems with bytes too large to fit into three octal digits must devise other means of displaying non-printable characters.
|
|
Consideration was given to requiring that the number of octal digits be large enough to hold a byte, but this seemed to be too
|
|
confusing for applications on the vast majority of systems where three digits are adequate. It would be theoretically possible for
|
|
the application to use the <a href="../utilities/getconf.html"><i>getconf</i></a> utility to find out the CHAR_BIT value and deal
|
|
with such an algorithm; however, there is really no portable way that an application can use the octal values of the bytes across
|
|
various coded character sets, so the additional specification was not worthwhile.</p>
|
|
|
|
<p>The description of how a NUL is written was removed. The NUL character cannot be in text files, and this volume of
|
|
IEEE Std 1003.1-2001 should not dictate behavior in the case of undefined, erroneous input.</p>
|
|
|
|
<p>Unlike some of the other editing utilities, the filenames accepted by the <b>E</b>, <b>e</b>, <b>R</b>, and <b>r</b> commands
|
|
are not patterns.</p>
|
|
|
|
<p>Early proposals stated that the <b>-p</b> option worked only when standard input was associated with a terminal device. This has
|
|
been changed to conform to historical implementations, thereby allowing applications to interpose themselves between a user and the
|
|
<i>ed</i> utility.</p>
|
|
|
|
<p>The form of the substitute command that uses the <b>n</b> suffix was limited in some historical documentation (where this was
|
|
described incorrectly as "backreferencing"). This limit has been omitted because there is no reason why an editor processing
|
|
lines of {LINE_MAX} length should have this restriction. The command <b>s/x/X/2047</b> should be able to substitute the 2047th
|
|
occurrence of <tt>'x'</tt> on a line.</p>
|
|
|
|
<p>The use of printing commands with printing suffixes (such as <b>pn</b>, <b>lp</b>, and so on) was made unspecified because
|
|
BSD-based systems allow this, whereas System V does not.</p>
|
|
|
|
<p>Some BSD-based systems exit immediately upon receipt of end-of-file if all of the lines in the file have been deleted. Since
|
|
this volume of IEEE Std 1003.1-2001 refers to the <b>q</b> command in this instance, such behavior is not allowed.</p>
|
|
|
|
<p>Some historical implementations returned exit status zero even if command errors had occurred; this is not allowed by this
|
|
volume of IEEE Std 1003.1-2001.</p>
|
|
|
|
<p>Some historical implementations contained a bug that allowed a single period to be entered in input mode as <backslash>
|
|
<period> <newline>. This is not allowed by <i>ed</i> because there is no description of escaping any of the characters
|
|
in input mode; backslashes are entered into the buffer exactly as typed. The typical method of entering a single period has been to
|
|
precede it with another character and then use the substitute command to delete that character.</p>
|
|
|
|
<p>It is difficult under some modes of some versions of historical operating system terminal drivers to distinguish between an
|
|
end-of-file condition and terminal disconnect. IEEE Std 1003.1-2001 does not require implementations to distinguish
|
|
between the two situations, which permits historical implementations of the <i>ed</i> utility on historical platforms to conform.
|
|
Implementations are encouraged to distinguish between the two, if possible, and take appropriate action on terminal disconnect.</p>
|
|
|
|
<p>Historically, <i>ed</i> accepted a zero address for the <b>a</b> and <b>r</b> commands in order to insert text at the start of
|
|
the edit buffer. When the buffer was empty the command <b>.=</b> returned zero. IEEE Std 1003.1-2001 requires conformance
|
|
to historical practice.</p>
|
|
|
|
<p>For consistency with the <b>a</b> and <b>r</b> commands and better user functionality, the <b>i</b> and <b>c</b> commands must
|
|
also accept an address of 0, in which case 0<i>i</i> is treated as 1<i>i</i> and likewise for the <b>c</b> command.</p>
|
|
|
|
<p>All of the following are valid addresses:</p>
|
|
|
|
<dl compact>
|
|
<dt><tt>+++</tt></dt>
|
|
|
|
<dd>Three lines after the current line.</dd>
|
|
|
|
<dt><tt>/</tt><i>pattern</i><tt>/-</tt></dt>
|
|
|
|
<dd>One line before the next occurrence of pattern.</dd>
|
|
|
|
<dt><tt>-2</tt></dt>
|
|
|
|
<dd>Two lines before the current line.</dd>
|
|
|
|
<dt><tt>3 ---- 2</tt></dt>
|
|
|
|
<dd>Line one (note the intermediate negative address).</dd>
|
|
|
|
<dt><tt>1 2 3</tt></dt>
|
|
|
|
<dd>Line six.</dd>
|
|
</dl>
|
|
|
|
<p>Any number of addresses can be provided to commands taking addresses; for example, <tt>"1,2,3,4,5p"</tt> prints lines 4 and 5,
|
|
because two is the greatest valid number of addresses accepted by the <b>print</b> command. This, in combination with the semicolon
|
|
delimiter, permits users to create commands based on ordered patterns in the file. For example, the command <tt>"3;/foo/;+2p"</tt>
|
|
will display the first line after line 3 that contains the pattern <i>foo</i>, plus the next two lines. Note that the address
|
|
<tt>"3;"</tt> must still be evaluated before being discarded, because the search origin for the <tt>"/foo/"</tt> command depends on
|
|
this.</p>
|
|
|
|
<p>Historically, <i>ed</i> disallowed address chains, as discussed above, consisting solely of comma or semicolon separators; for
|
|
example, <tt>",,,"</tt> or <tt>";;;"</tt> were considered an error. For consistency of address specification, this restriction is
|
|
removed. The following table lists some of the address forms now possible:</p>
|
|
|
|
<center>
|
|
<table border="1" cellpadding="3" align="center">
|
|
<tr valign="top">
|
|
<th align="center">
|
|
<p class="tent"><b>Address</b></p>
|
|
</th>
|
|
<th align="center">
|
|
<p class="tent"><b>Addr1</b></p>
|
|
</th>
|
|
<th align="center">
|
|
<p class="tent"><b>Addr2</b></p>
|
|
</th>
|
|
<th align="center">
|
|
<p class="tent"><b>Status</b></p>
|
|
</th>
|
|
<th align="center">
|
|
<p class="tent"><b>Comment</b></p>
|
|
</th>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7,</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7,5,</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">5</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">5</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7,5,9</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">5</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">9</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7,9</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">9</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7,+</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">8</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">,</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">1</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">,7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">1</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Extension</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">,,</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Extension</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">,;</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Extension</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7;</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7;5;</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">5</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">5</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7;5;9</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">5</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">9</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7;5,9</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">5</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">9</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7;$;4</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">4</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Valid, but erroneous.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7;9</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">9</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">7;+</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">8</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">;</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">.</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Historical</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">;7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">.</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">7</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Extension</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">;;</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Extension</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent">;,</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">$</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">Extension</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
|
|
<p>Historically, values could be added to addresses by including them after one or more <blank>s; for example,
|
|
<tt>"3 - 5p"</tt> wrote the seventh line of the file, and <tt>"/foo/ 5"</tt> was the same as <tt>"5 /foo/"</tt>
|
|
. However, only absolute values could be added; for example, <tt>"5 /foo/"</tt> was an error. IEEE Std 1003.1-2001
|
|
requires conformance to historical practice.</p>
|
|
|
|
<p>Historically, <i>ed</i> accepted the <tt>'^'</tt> character as an address, in which case it was identical to the hyphen
|
|
character. IEEE Std 1003.1-2001 does not require or prohibit this behavior.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_19"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_20"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="xcu_chap01.html#tag_01_11"><i>Utility Description Defaults</i></a> , <a href="ex.html"><i>ex</i></a> , <a href=
|
|
"sed.html"><i>sed</i></a> , <a href="sh.html"><i>sh</i></a> , <a href="vi.html"><i>vi</i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_21"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 2.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_22"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>In the OPTIONS section, the meaning of <b>-s</b> and <b>-</b> is clarified.</p>
|
|
|
|
<p>A second FUTURE DIRECTION is added.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_42_23"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The obsolescent single-minus form is removed.</p>
|
|
|
|
<p>A second APPLICATION USAGE note is added.</p>
|
|
|
|
<p>The Open Group Corrigendum U025/2 is applied, correcting the description of the Edit section.</p>
|
|
|
|
<p>The <i>ed</i> utility is updated to align with the IEEE P1003.2b draft standard. This includes addition of the treatment of
|
|
the SIGQUIT signal, changes to <i>ed</i> addressing, and changes to processing when end-of-file is detected and when terminal
|
|
disconnect is detected.</p>
|
|
|
|
<p>The normative text is reworded to avoid use of the term "must" for application requirements.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|