⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ed.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 3 页
字号:
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>.<h5><a name = "tag_001_014_541_021">&nbsp;</a>Prompt Command</h5><pre><code><i>Synopsis</i>:	P</code></pre><p>The<b>P</b>command causes<i>ed</i>to prompt with an asterisk(*)(or<i>string</i>,if<b>-p</b>is specified)for all subsequent commands.The<b>P</b>command alternatively turns this mode on and off; it isinitially on if the<b>-p</b>option is specified, otherwise off.The current line number is unchanged.<h5><a name = "tag_001_014_541_022">&nbsp;</a>Quit Command</h5><pre><code><i>Synopsis</i>:	q</code></pre><p>The<b>q</b>command causes<i>ed</i>to exit.If the buffer has changed since the last time the entire bufferwas written, the user will be warned, as described previously.<h5><a name = "tag_001_014_541_023">&nbsp;</a>Quit Without Checking Command</h5><pre><code><i>Synopsis</i>:	Q</code></pre><p>The<b>Q</b>command causes<i>ed</i>to exit withoutchecking if changes have been made in the buffer since the last<b>w</b>command.<h5><a name = "tag_001_014_541_024">&nbsp;</a>Read Command</h5><pre><code><i>Synopsis</i>:	($)r<b>[</b><i>file</i><b>]</b></code></pre><p><br>The<b>r</b>command reads in the file named by the pathname<i>file</i>and appends it after the addressed line.If no<i>file</i>argument is given, the currently remembered pathname,if any, will be used(see<b>e</b>and<b>f</b>commands).The currently remembered pathname will not be changed unlessthere is no remembered pathname.Address 0 is valid for<b>r</b>and causes 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 bytesread will be written to standard outputin the following format:<p><code><tt>"%d\n"</tt>, &lt;<i>number&nbsp;of&nbsp;bytes&nbsp;read</i>&gt;</code>The current line number will be set to the address of the last line read in.If<i>file</i>is replaced by<b>!</b>,the rest of the linewill be taken to be ashell command line whose output is to be read.Such a shell command line will not be remembered as the current pathname.<h5><a name = "tag_001_014_541_025">&nbsp;</a>Substitute Command</h5><pre><code><i>Synopsis</i>:	(.,.)s/<i>RE</i>/<i>replacement</i>/<i>flags</i></code></pre><p>The<b>s</b>command searches each addressedline for an occurrence of the specified REand replace either the first orall (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 newlinecan be used instead of a slash to delimit the<i>RE</i>and the replacement.Within the<i>RE</i>,the<i>RE</i>delimiter itself can be used as a literalcharacter if it is preceded by a backslash.The current line will be set to the address of the last lineon which a substitution occurred.<p>An ampersand(&amp;)appearing in the<i>replacement</i>will be replaced by the string matching the RE on the current line.The special meaning of "&amp;"in this context can besuppressed by preceding it by backslash.As a more general feature,the characters<b>\</b><i>n</i>,where<i>n</i>is a digit,will be replaced by the text matched by thecorresponding back-reference expression.When the character"%"is the only characterin the<i>replacement</i>,the<i>replacement</i>used in the most recent substitutecommand will be used as the<i>replacement</i>in the current substitute command;if there was no previous substitute command,the use of"%"in this manner is an error.The"%"loses its special meaning when it isin a replacement string of more than onecharacter or is preceded by a backslash.For each backslash (\) encountered in scanning<i>replacement</i>from beginning to end, the following character loses its special meaning(if any).It is unspecified what special meaning is given to any characterother than "&amp;", "\" "%" or digits.<p>A line can be split by substituting a newline character into it.The application must escape the newline character 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> command list.The current line number will be set to the address of the last lineon which a substitution is performed.If no substitution isperformed, the current line number is unchanged.If a line issplit, a substitution is considered to have been performed oneach of the new lines for the purpose of determining the newcurrent line number.A substitution is considered to have beenperformed even if the replacement string is identical to thestring that it replaces.<p>The value of<i>flags</i>must be zero or more of:<dl compact><dt><i>count</i><dd>Substitute for the<i>count</i>thoccurrence only of the<i>RE</i>found on each addressed line.<dt><b>g</b><dd>Globally substitute for all non-overlapping instances of the<i>RE</i>rather than just the first one.If both<b>g</b>and<i>count</i>are specified,the results are unspecified.<dt><b>l</b><dd>Write to standard outputthe final line in which a substitution was made.The line will be writtenin the format specified for the<b>l</b>command.<dt><b>n</b><dd>Write to standard outputthe final line in which a substitution was made.The line will be writtenin the format specified for the<b>n</b>command.<dt><b>p</b><dd>Write to standard outputthe final line in which a substitution was made.The line will be writtenin the format specified for the<b>p</b>command.</dl><h5><a name = "tag_001_014_541_026">&nbsp;</a>Copy Command</h5><pre><code><i>Synopsis</i>:	(.,.)t<i>address</i></code></pre><p>The<b>t</b>command is equivalent to the<b>m</b>command, except that a copy of the addressed lines will be placedafter address<i>address</i>(which can be 0);the current line number will be set to the address of the last line added.<h5><a name = "tag_001_014_541_027">&nbsp;</a>Undo Command</h5><pre><code><i>Synopsis</i>:	u</code></pre><p>The<b>u</b>command nullifies the effect of the most recentcommand that modified anything in the buffer, namelythe 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 will be undone as a single change;if no changes were made by the global command (such as with<b>g/</b>REthe<b>u</b>command will have no effect.The current line number will be set to the value it hadimmediately before thecommand being undone started.<h5><a name = "tag_001_014_541_028">&nbsp;</a>Global Non-matched Command</h5><pre><code><i>Synopsis</i>:	(1,$)v/<i>RE</i>/<i>command list</i></code></pre><p>This command is equivalent to the global command<b>g</b>except that thelines that are marked during the first step will be those that donot match the<i>RE</i>.<h5><a name = "tag_001_014_541_029">&nbsp;</a>Interactive Global Not-matched Command</h5><pre><code><i>Synopsis</i>:	(1,$)V/<i>RE</i>/</code></pre><p>This command is equivalent to the interactive global command<b>G</b> exceptthat the lines that are marked during the first step will be those that donot match the<i>RE</i>.<h5><a name = "tag_001_014_541_030">&nbsp;</a>Write Command</h5><pre><code><i>Synopsis</i>:	(1,$)w<b>[</b><i>file</i><b>]</b></code></pre><p>The<b>w</b>command writes the addressed lines intothe file named by the pathname<i>file</i>.The command will create the file, if it does not exist, orwill replace the contents of the existing file.The currently remembered pathname will not be changed unlessthere is no remembered pathname.If no pathname is given, the currently remembered pathname, if any,will be used (see the<b>e</b>and<b>f</b>commands); the current line number is unchanged.If the command is successful, the number of bytes written will bewritten to standard output, unless the<b>-s</b>option was specified, in the following format:<p><code><tt>"%d\n"</tt>, &lt;<i>number&nbsp;of&nbsp;bytes&nbsp;written</i>&gt;</code><p>If<i>file</i>begins with "!", the rest of the line will be taken to be ashell command line whose standard input will be the addressed lines.Such a shell command line will not be remembered as the current pathname.This usage of the write command with "!" will not be considered as a &quot;last<b>w</b>command that wrote the entire buffer&quot;, as described previously;thus, this alone will not preventthe warning to the user if an attempt is made to destroythe editor buffer via the<b>e</b>or<b>q</b>commands.<h5><a name = "tag_001_014_541_031">&nbsp;</a>Line Number Command</h5><pre><code><i>Synopsis</i>:	($)=</code></pre><p>The line number of the addressed line will bewritten to standard outputin the following format:<p><code><tt>"%d\n"</tt>, &lt;<i>line&nbsp;number</i>&gt;</code><p>The current line number is unchanged by this command.<h5><a name = "tag_001_014_541_032">&nbsp;</a>Shell Escape Command</h5><pre><code><i>Synopsis</i>:	!<i>command</i></code></pre><p>The remainder of the line after the<b>!</b>will be sentto the command interpreterto be interpreted as a shell command line.Within the text of that shell command line, the unescaped character<b>%</b>will be replaced with the remembered pathname;if a<b>!</b>appears as the first character of the command,it will be replaced with the text of the previous shell commandexecuted via<b>!</b>.Thus,<b>!!</b>will repeat the previous<b>!</b>commandIf any replacements of<b>%</b>or<b>!</b>are performed, the modified line will be writtento the standard output before<i>command</i>is executed.The<b>!</b>command will write:<pre><code>"!\n"</code></pre>to standard output upon completion, unless the<b>-s</b>option is specified.The current line number is unchanged.<h5><a name = "tag_001_014_541_033">&nbsp;</a>Null Command</h5><pre><code><i>Synopsis</i>:	(.+1)</code></pre><p>An address alone on a line causes the addressed line to be written.A newline character alone is equivalent to.+1p.The current line number will be set to the address of the written line.</blockquote><h4><a name = "tag_001_014_542">&nbsp;</a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>Successful completion without any file or command errors.<dt>&gt;0<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_543">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>When an error in the input script is encountered, or whenan error is detected that is a consequence of the data(not) present in the file or due to an external conditionsuch as a read or write error:<ul><p><li>If the standard input is a terminal device file,all input will be flushed, and a new command read.<p><li>If the standard input is a regular file,<i>ed</i>will terminate with a non-zero exit status.<p></ul></blockquote><h4><a name = "tag_001_014_544">&nbsp;</a>APPLICATION USAGE</h4><blockquote>Because of the extremely terse nature of the default errormessages, the prudent script writerwill begin the<i>ed</i>input commands with an<b>H</b>command, so that if any errors do occur atleast some clue as to the cause will be made available.</blockquote><h4><a name = "tag_001_014_545">&nbsp;</a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_546">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>The obsolescent single-minus form may be withdrawn in a future issue.Applications should use the<b>-s</b>option.<p>The IEEE PASC 1003.2 Interpretations Committee has forwarded concerns about parts of this interface definition to the IEEE PASC Shell and Utilities Working Groupwhich is identifying the corrections.A future revision of this specification will align withIEEE Std. 1003.2b when finalised.</blockquote><h4><a name = "tag_001_014_547">&nbsp;</a>SEE ALSO</h4><blockquote><i><a href="ex.html">ex</a></i>,<i><a href="sed.html">sed</a></i>,<i><a href="sh.html">sh</a></i>,<i><a href="vi.html">vi</a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX &reg; is a registered Trademark of The Open Group.<br>Copyright &copy; 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -