📄 ch10_01.htm
字号:
<html><head><title>The sed Editor (UNIX in a Nutshell: System V Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Arnold Robbins" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly & Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="1-56592-427-4" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="UNIX in a Nutshell: System V Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Book Title" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch09_02.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch10_02.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h1 class="chapter">Chapter 10. The sed Editor</h1><div class="htmltoc"><h4 class="tochead">Contents:</h4><p><a href="ch10_01.htm#sect1">Conceptual Overview</a><br /><a href="ch10_02.htm">Command-Line Syntax</a><br /><a href="ch10_03.htm">Syntax of sed Commands</a><br /><a href="ch10_04.htm">Group Summary of sed Commands</a><br /><a href="ch10_05.htm">Alphabetical Summary of sed Commands</a><br /></p></div><p><a name="unut-ch-10-ix-sed-editor" />This chapter presents the following topics:</p><ul><li><p>Conceptual overview of <tt class="literal">sed</tt></p></li><li><p>Command-line syntax</p></li><li><p>Syntax of <tt class="literal">sed</tt> commands</p></li><li><p>Group summary of <tt class="literal">sed</tt> commands</p></li><li><p>Alphabetical summary of <tt class="literal">sed</tt> commands</p></li></ul><p>For more information, see <em class="citetitle">sed & awk</em>,listed in the <a href="biblio.htm">Bibliography</a>.</p><div class="sect1"><a name="unut-ch-10-sect-1" /><h2 class="sect1"><a name="sect1" />10.1. Conceptual Overview</h2><p><tt class="literal">sed</tt> is a noninteractive,or <b class="emphasis-bold">s</b>tream-oriented, <b class="emphasis-bold">ed</b>itor. It interprets a script and performs the actions in the script.<tt class="literal">sed</tt> is stream-oriented because,like many Unix programs, input flows through the program and is directed to standard output.For example, <tt class="literal">sort</tt> is stream-oriented;<tt class="literal">vi</tt> is not.<tt class="literal">sed</tt>'s input typically comes froma file or pipe but can be directed from the keyboard. Output goes to the screen by default but can be captured in a file or sentthrough a pipe instead.</p><a name="unut-ch-10-sect-1.1" /><div class="sect2"><h3 class="sect2">10.1.1. Typical Uses of sed Include:</h3><ul><li><p>Editing one or more files automatically.</p></li><li><p>Simplifying repetitive edits to multiple files.</p></li><li><p>Writing conversion programs.</p></li></ul></div><a name="unut-ch-10-sect-1.2" /><div class="sect2"><h3 class="sect2">10.1.2. sed Operates as Follows:</h3><ul><li><p>Each line of input is copied into a “pattern space,”an internal buffer where editing operations are performed.</p></li><li><p>All editing commands in a <tt class="literal">sed</tt> script are applied,in order, to each line of input.</p></li><li><p>Editing commands are applied to all lines (globally) unless lineaddressing restricts the lines affected.</p></li><li><p>If a command changes the input, subsequent commands and address testsare applied to the current line in the pattern space, not the original input line.</p></li><li><p>The original input file is unchanged because the editing commands modify a copy of each original input line. The copy is sent to standard output(but can be redirected to a file).</p></li><li><p><tt class="literal">sed</tt> also maintains the “hold space,”a separate buffer that can be used to save data for later retrieval.</p></li></ul></div></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch09_02.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch10_02.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">9.2. Alphabetical Summary of ex Commands</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">10.2. Command-Line Syntax</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2003</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,88,96" href="../index.htm"><area shape="rect" coords="90,0,165,96" href="../upt/index.htm"><area shape="rect" coords="168,1,253,107" href="../mac/index.htm"><area shape="rect" coords="255,0,335,97" href="../korn/index.htm"><area shape="rect" coords="337,0,415,109" href="../unixnut/index.htm"><area shape="rect" coords="417,0,512,122" href="../sedawk/index.htm"><area shape="rect" coords="514,0,605,105" href="../lunix/index.htm"><area shape="rect" coords="611,2,694,121" href="../vi/index.htm"> </map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -