<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sed | 酷 壳 - CoolShell</title>
	<atom:link href="https://coolshell.cn/tag/sed/feed" rel="self" type="application/rss+xml" />
	<link>https://coolshell.cn</link>
	<description>享受编程和技术所带来的快乐 - Coding Your Ambition</description>
	<lastBuildDate>Thu, 13 Jul 2017 06:02:33 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2</generator>
	<item>
		<title>sed 简明教程</title>
		<link>https://coolshell.cn/articles/9104.html</link>
					<comments>https://coolshell.cn/articles/9104.html#comments</comments>
		
		<dc:creator><![CDATA[陈皓]]></dc:creator>
		<pubDate>Wed, 20 Feb 2013 00:36:48 +0000</pubDate>
				<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[编程工具]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[Unix]]></category>
		<guid isPermaLink="false">http://coolshell.cn/?p=9104</guid>

					<description><![CDATA[<p>awk于1977年出生，今年36岁本命年，sed比awk大2-3岁，awk就像林妹妹，sed就是宝玉哥哥了。所以 林妹妹跳了个Topless，他的哥哥sed坐不...</p>
<p class="read-more"><a class="btn btn-default" href="https://coolshell.cn/articles/9104.html"> Read More<span class="screen-reader-text">  Read More</span></a></p>
The post <a href="https://coolshell.cn/articles/9104.html">sed 简明教程</a> first appeared on <a href="https://coolshell.cn">酷 壳 - CoolShell</a>.]]></description>
										<content:encoded><![CDATA[<p><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3415450859608158"
     crossorigin="anonymous"></script><img decoding="async" loading="lazy" class="alignright wp-image-9126" src="https://coolshell.cn/wp-content/uploads/2013/02/sed-superman.png" alt="" width="216" height="216" srcset="https://coolshell.cn/wp-content/uploads/2013/02/sed-superman.png 270w, https://coolshell.cn/wp-content/uploads/2013/02/sed-superman-150x150.png 150w, https://coolshell.cn/wp-content/uploads/2013/02/sed-superman-200x200.png 200w" sizes="(max-width: 216px) 100vw, 216px" />awk于1977年出生，今年36岁本命年，sed比awk大2-3岁，awk就像林妹妹，sed就是宝玉哥哥了。所以 <a title="AWK 简明教程" href="https://coolshell.cn/articles/9070.html" target="_blank" rel="noopener noreferrer">林妹妹跳了个Topless</a>，他的哥哥sed坐不住了，也一定要出来抖一抖。</p>
<p>sed全名叫stream editor，流编辑器，用程序的方式来编辑文本，相当的hacker啊。sed基本上就是玩正则模式匹配，所以，玩sed的人，正则表达式一般都比较强。</p>
<p>同样，本篇文章不会说sed的全部东西，你可以参看<a href="http://www.gnu.org/software/sed/manual/sed.html" target="_blank" rel="noopener noreferrer">sed的手册</a>，我这里主要还是想和大家竞争一下那些从手机指缝间或马桶里流走的时间，用这些时间来学习一些东西。当然，接下来的还是要靠大家自己双手。</p>
<h4>用s命令替换</h4>
<p>我使用下面的这段文本做演示：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ cat pets.txt
This is my cat
  my cat&#039;s name is betty
This is my dog
  my dog&#039;s name is frank
This is my fish
  my fish&#039;s name is george
This is my goat
  my goat&#039;s name is adam</pre>
<p>把其中的my字符串替换成Hao Chen&#8217;s，下面的语句应该很好理解（s表示替换命令，/my/表示匹配my，/Hao Chen&#8217;s/表示把匹配替换成Hao Chen&#8217;s，/g 表示一行上的替换所有的匹配）：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &quot;s/my/Hao Chen&#039;s/g&quot; pets.txt
This is Hao Chen&#039;s cat
  Hao Chen&#039;s cat&#039;s name is betty
This is Hao Chen&#039;s dog
  Hao Chen&#039;s dog&#039;s name is frank
This is Hao Chen&#039;s fish
  Hao Chen&#039;s fish&#039;s name is george
This is Hao Chen&#039;s goat
  Hao Chen&#039;s goat&#039;s name is adam</pre>
<p>注意：如果你要使用单引号，那么你没办法通过\&#8217;这样来转义，就有双引号就可以了，在双引号内可以用\&#8221;来转义。</p>
<p><span id="more-9104"></span></p>
<p>再注意：上面的sed并没有对文件的内容改变，只是把处理过后的内容输出，如果你要写回文件，你可以使用重定向，如：</p>
<p><code data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &quot;s/my/Hao Chen&#039;s/g&quot; pets.txt &gt; hao_pets.txt</code></p>
<p>或使用 -i 参数直接修改文件内容：</p>
<p><code data-enlighter-language="shell" class="EnlighterJSRAW">$ sed -i &quot;s/my/Hao Chen&#039;s/g&quot; pets.txt</code></p>
<p>在每一行最前面加点东西：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;s/^/#/g&#039; pets.txt
#This is my cat
#  my cat&#039;s name is betty
#This is my dog
#  my dog&#039;s name is frank
#This is my fish
#  my fish&#039;s name is george
#This is my goat
#  my goat&#039;s name is adam</pre>
<p>在每一行最后面加点东西：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;s/$/ --- /g&#039; pets.txt
This is my cat ---
  my cat&#039;s name is betty ---
This is my dog ---
  my dog&#039;s name is frank ---
This is my fish ---
  my fish&#039;s name is george ---
This is my goat ---
  my goat&#039;s name is adam ---</pre>
<p>顺手介绍一下正则表达式的一些最基本的东西：</p>
<ul>
<li> <code>^</code> 表示一行的开头。如：<code>/^#/</code> 以#开头的匹配。</li>
<li> <code>$</code> 表示一行的结尾。如：<code>/}$/</code> 以}结尾的匹配。</li>
<li> <code>&#92;&lt;</code> 表示词首。 如：<code>&#92;&lt;abc</code> 表示以 abc 为首的詞。</li>
<li> <code>&#92;&gt;</code> 表示词尾。 如：<code>abc&#92;&gt;</code> 表示以 abc 結尾的詞。</li>
<li> <code>.</code> 表示任何单个字符。</li>
<li> <code>*</code> 表示某个字符出现了0次或多次。</li>
<li> <code>&#91; &#93;</code> 字符集合。 如：<code>&#91;abc&#93;</code> 表示匹配a或b或c，还有 <code>&#91;a-zA-Z&#93;</code> 表示匹配所有的26个字符。如果其中有^表示反，如 <code>&#91;^a&#93;</code> 表示非a的字符</li>
</ul>
<p>正规则表达式是一些很牛的事，比如我们要去掉某html中的tags：</p>
<pre data-enlighter-language="html" class="EnlighterJSRAW">

&lt;b&gt;This&lt;/b&gt; is what &lt;span style=&quot;text-decoration: underline;&quot;&gt;I&lt;/span&gt; meant. Understand?

</pre>
<p>看看我们的sed命令</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">
# 如果你这样搞的话，就会有问题
$ sed &#039;s/&lt;.*&gt;//g&#039; html.txt
 Understand?

# 要解决上面的那个问题，就得像下面这样。
# 其中的&#039;[^&gt;]&#039; 指定了除了&gt;的字符重复0次或多次。
$ sed &#039;s/&lt;[^&gt;]*&gt;//g&#039; html.txt
This is what I meant. Understand?</pre>
<p>我们再来看看指定需要替换的内容：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW" data-enlighter-highlight="4">$ sed &quot;3s/my/your/g&quot; pets.txt
This is my cat
  my cat&#039;s name is betty
This is your dog
  my dog&#039;s name is frank
This is my fish
  my fish&#039;s name is george
This is my goat
  my goat&#039;s name is adam</pre>
<p>下面的命令只替换第3到第6行的文本。</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW" data-enlighter-highlight="4,5,6,7">$ sed &quot;3,6s/my/your/g&quot; pets.txt
This is my cat
  my cat&#039;s name is betty
This is your dog
  your dog&#039;s name is frank
This is your fish
  your fish&#039;s name is george
This is my goat
  my goat&#039;s name is adam</pre>
<p>&nbsp;</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ cat my.txt
This is my cat, my cat&#039;s name is betty
This is my dog, my dog&#039;s name is frank
This is my fish, my fish&#039;s name is george
This is my goat, my goat&#039;s name is adam</pre>
<p>只替换每一行的第一个s：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;s/s/S/1&#039; my.txt
ThiS is my cat, my cat&#039;s name is betty
ThiS is my dog, my dog&#039;s name is frank
ThiS is my fish, my fish&#039;s name is george
ThiS is my goat, my goat&#039;s name is adam</pre>
<p>只替换每一行的第二个s：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;s/s/S/2&#039; my.txt
This iS my cat, my cat&#039;s name is betty
This iS my dog, my dog&#039;s name is frank
This iS my fish, my fish&#039;s name is george
This iS my goat, my goat&#039;s name is adam</pre>
<p>只替换第一行的第3个以后的s：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;s/s/S/3g&#039; my.txt
This is my cat, my cat&#039;S name iS betty
This is my dog, my dog&#039;S name iS frank
This is my fiSh, my fiSh&#039;S name iS george
This is my goat, my goat&#039;S name iS adam</pre>
<h4>多个匹配</h4>
<p>如果我们需要一次替换多个模式，可参看下面的示例：（第一个模式把第一行到第三行的my替换成your，第二个则把第3行以后的This替换成了That）</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;1,3s/my/your/g; 3,$s/This/That/g&#039; my.txt
This is your cat, your cat&#039;s name is betty
This is your dog, your dog&#039;s name is frank
That is your fish, your fish&#039;s name is george
That is my goat, my goat&#039;s name is adam</pre>
<p>上面的命令等价于：（注：下面使用的是sed的-e命令行参数）</p>
<p><code data-enlighter-language="shell" class="EnlighterJSRAW">sed -e &#039;1,3s/my/your/g&#039; -e &#039;3,$s/This/That/g&#039; my.txt</code></p>
<p>我们可以使用&amp;来当做被匹配的变量，然后可以在基本左右加点东西。如下所示：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;s/my/[&amp;]/g&#039; my.txt
This is [my] cat, [my] cat&#039;s name is betty
This is [my] dog, [my] dog&#039;s name is frank
This is [my] fish, [my] fish&#039;s name is george
This is [my] goat, [my] goat&#039;s name is adam</pre>
<h4>圆括号匹配</h4>
<p>使用圆括号匹配的示例：（圆括号括起来的正则表达式所匹配的字符串会可以当成变量来使用，sed中使用的是\1,\2&#8230;）</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;s/This is my \([^,&amp;]*\),.*is \(.*\)/\1:\2/g&#039; my.txt
cat:betty
dog:frank
fish:george
goat:adam</pre>
<p>上面这个例子中的正则表达式有点复杂，解开如下（去掉转义字符）：</p>
<p>正则为：This is my (&#91;^,&#93;*),.*is (.*)<br />
匹配为：This is my (cat),&#8230;&#8230;&#8230;.is (betty)</p>
<p>然后：\1就是cat，\2就是betty</p>
<h4>sed的命令</h4>
<p>让我们回到最一开始的例子pets.txt，让我们来看几个命令：</p>
<h5>N命令</h5>
<p>先来看N命令 —— 把下一行的内容纳入当成缓冲区做匹配。</p>
<p>下面的的示例会把原文本中的偶数行纳入奇数行匹配，而s只匹配并替换一次，所以，就成了下面的结果：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;N;s/my/your/&#039; pets.txt
This is your cat
  my cat&#039;s name is betty
This is your dog
  my dog&#039;s name is frank
This is your fish
  my fish&#039;s name is george
This is your goat
  my goat&#039;s name is adam</pre>
<p>也就是说，原来的文件成了：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">This is my cat\n  my cat&#039;s name is betty
This is my dog\n  my dog&#039;s name is frank
This is my fish\n  my fish&#039;s name is george
This is my goat\n  my goat&#039;s name is adam</pre>
<p>这样一来，下面的例子你就明白了，</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;N;s/\n/,/&#039; pets.txt
This is my cat,  my cat&#039;s name is betty
This is my dog,  my dog&#039;s name is frank
This is my fish,  my fish&#039;s name is george
This is my goat,  my goat&#039;s name is adam</pre>
<h5>a命令和i命令</h5>
<p>a命令就是append， i命令就是insert，它们是用来添加行的。如：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW" data-enlighter-highlight="2,12"># 其中的1i表明，其要在第1行前插入一行（insert）
$ sed &quot;1 i This is my monkey, my monkey&#039;s name is wukong&quot; my.txt
This is my monkey, my monkey&#039;s name is wukong
This is my cat, my cat&#039;s name is betty
This is my dog, my dog&#039;s name is frank
This is my fish, my fish&#039;s name is george
This is my goat, my goat&#039;s name is adam

# 其中的1a表明，其要在最后一行后追加一行（append）
$ sed &quot;$ a This is my monkey, my monkey&#039;s name is wukong&quot; my.txt
This is my cat, my cat&#039;s name is betty
This is my monkey, my monkey&#039;s name is wukong
This is my dog, my dog&#039;s name is frank
This is my fish, my fish&#039;s name is george
This is my goat, my goat&#039;s name is adam</pre>
<p>我们可以运用匹配来添加文本：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW" data-enlighter-highlight="6"># 注意其中的/fish/a，这意思是匹配到/fish/后就追加一行
$ sed &quot;/fish/a This is my monkey, my monkey&#039;s name is wukong&quot; my.txt
This is my cat, my cat&#039;s name is betty
This is my dog, my dog&#039;s name is frank
This is my fish, my fish&#039;s name is george
This is my monkey, my monkey&#039;s name is wukong
This is my goat, my goat&#039;s name is adam</pre>
<p>下面这个例子是对每一行都挺插入：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &quot;/my/a ----&quot; my.txt
This is my cat, my cat&#039;s name is betty
----
This is my dog, my dog&#039;s name is frank
----
This is my fish, my fish&#039;s name is george
----
This is my goat, my goat&#039;s name is adam
----</pre>
<h5>c命令</h5>
<p>c 命令是替换匹配行</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &quot;2 c This is my monkey, my monkey&#039;s name is wukong&quot; my.txt
This is my cat, my cat&#039;s name is betty
This is my monkey, my monkey&#039;s name is wukong
This is my fish, my fish&#039;s name is george
This is my goat, my goat&#039;s name is adam

$ sed &quot;/fish/c This is my monkey, my monkey&#039;s name is wukong&quot; my.txt
This is my cat, my cat&#039;s name is betty
This is my dog, my dog&#039;s name is frank
This is my monkey, my monkey&#039;s name is wukong
This is my goat, my goat&#039;s name is adam</pre>
<h5>d命令</h5>
<p>删除匹配行</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ sed &#039;/fish/d&#039; my.txt
This is my cat, my cat&#039;s name is betty
This is my dog, my dog&#039;s name is frank
This is my goat, my goat&#039;s name is adam

$ sed &#039;2d&#039; my.txt
This is my cat, my cat&#039;s name is betty
This is my fish, my fish&#039;s name is george
This is my goat, my goat&#039;s name is adam

$ sed &#039;2,$d&#039; my.txt
This is my cat, my cat&#039;s name is betty</pre>
<h5>p命令</h5>
<p>打印命令</p>
<p>你可以把这个命令当成grep式的命令</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW"># 匹配fish并输出，可以看到fish的那一行被打了两遍，
# 这是因为sed处理时会把处理的信息输出
$ sed &#039;/fish/p&#039; my.txt
This is my cat, my cat&#039;s name is betty
This is my dog, my dog&#039;s name is frank
This is my fish, my fish&#039;s name is george
This is my fish, my fish&#039;s name is george
This is my goat, my goat&#039;s name is adam

# 使用n参数就好了
$ sed -n &#039;/fish/p&#039; my.txt
This is my fish, my fish&#039;s name is george

# 从一个模式到另一个模式
$ sed -n &#039;/dog/,/fish/p&#039; my.txt
This is my dog, my dog&#039;s name is frank
This is my fish, my fish&#039;s name is george

#从第一行打印到匹配fish成功的那一行
$ sed -n &#039;1,/fish/p&#039; my.txt
This is my cat, my cat&#039;s name is betty
This is my dog, my dog&#039;s name is frank
This is my fish, my fish&#039;s name is george</pre>
<h4>几个知识点</h4>
<p>好了，下面我们要介绍四个sed的基本知识点：</p>
<h5>Pattern Space</h5>
<p>第零个是关于-n参数的，大家也许没看懂，没关系，我们来看一下sed处理文本的伪代码，并了解一下Pattern Space的概念：</p>
<pre data-enlighter-language="c" class="EnlighterJSRAW">foreach line in file {
    //放入把行Pattern_Space
    Pattern_Space &lt;= line;

    // 对每个pattern space执行sed命令
    Pattern_Space &lt;= EXEC(sed_cmd, Pattern_Space);

    // 如果没有指定 -n 则输出处理后的Pattern_Space
    if (sed option hasn&#039;t &quot;-n&quot;)  {
       print Pattern_Space
    }
}</pre>
<h5>Address</h5>
<p>第一个是关于address，几乎上述所有的命令都是这样的（注：其中的!表示匹配成功后是否执行命令）</p>
<p><strong>&#91;address&#91;,address&#93;&#93;&#91;!&#93;{cmd}</strong></p>
<p>address可以是一个数字，也可以是一个模式，你可以通过逗号要分隔两个address 表示两个address的区间，参执行命令cmd，伪代码如下：</p>
<pre data-enlighter-language="c" class="EnlighterJSRAW">
bool bexec = false
foreach line in file {
    if ( match(address1) ){
        bexec = true;
    }

    if ( bexec == true) {
        EXEC(sed_cmd);
    }

    if ( match (address2) ) {
        bexec = false;
    }
}</pre>
<p>关于address可以使用相对位置，如：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW"># 其中的+3表示后面连续3行
$ sed &#039;/dog/,+3s/^/# /g&#039; pets.txt
This is my cat
  my cat&#039;s name is betty
# This is my dog
#   my dog&#039;s name is frank
# This is my fish
#   my fish&#039;s name is george
This is my goat
  my goat&#039;s name is adam</pre>
<h5>命令打包</h5>
<p>第二个是cmd可以是多个，它们可以用分号分开，可以用大括号括起来作为嵌套命令。下面是几个例子：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW" data-enlighter-highlight="12,21,31">$ cat pets.txt
This is my cat
  my cat&#039;s name is betty
This is my dog
  my dog&#039;s name is frank
This is my fish
  my fish&#039;s name is george
This is my goat
  my goat&#039;s name is adam

# 对3行到第6行，执行命令/This/d
$ sed &#039;3,6 {/This/d}&#039; pets.txt
This is my cat
  my cat&#039;s name is betty
  my dog&#039;s name is frank
  my fish&#039;s name is george
This is my goat
  my goat&#039;s name is adam

# 对3行到第6行，匹配/This/成功后，再匹配/fish/，成功后执行d命令
$ sed &#039;3,6 {/This/{/fish/d}}&#039; pets.txt
This is my cat
  my cat&#039;s name is betty
This is my dog
  my dog&#039;s name is frank
  my fish&#039;s name is george
This is my goat
  my goat&#039;s name is adam

# 从第一行到最后一行，如果匹配到This，则删除之；如果前面有空格，则去除空格
$ sed &#039;1,${/This/d;s/^ *//g}&#039; pets.txt
my cat&#039;s name is betty
my dog&#039;s name is frank
my fish&#039;s name is george
my goat&#039;s name is adam </pre>
<h5>Hold Space</h5>
<p>第三个我们再来看一下 Hold Space</p>
<p>接下来，我们需要了解一下Hold Space的概念，我们先来看四个命令：</p>
<p>g： 将hold space中的内容拷贝到pattern space中，原来pattern space里的内容清除<br />
G： 将hold space中的内容append到pattern space\n后<br />
h： 将pattern space中的内容拷贝到hold space中，原来的hold space里的内容被清除<br />
H： 将pattern space中的内容append到hold space\n后<br />
x： 交换pattern space和hold space的内容</p>
<p>这些命令有什么用？我们来看两个示例吧，用到的示例文件是：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW">$ cat t.txt
one
two
three</pre>
<p>第一个示例：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW" data-enlighter-highlight="1">$ sed &#039;H;g&#039; t.txt
one

one
two

one
two
three</pre>
<p>是不是有点没看懂，我作个图你就看懂了。</p>
<p><img decoding="async" loading="lazy" class="aligncenter size-full wp-image-9118" src="https://coolshell.cn/wp-content/uploads/2013/02/sed_demo_00.jpg" alt="" width="592" height="404" srcset="https://coolshell.cn/wp-content/uploads/2013/02/sed_demo_00.jpg 592w, https://coolshell.cn/wp-content/uploads/2013/02/sed_demo_00-300x204.jpg 300w" sizes="(max-width: 592px) 100vw, 592px" /></p>
<p>第二个示例，反序了一个文件的行：</p>
<pre data-enlighter-language="shell" class="EnlighterJSRAW" data-enlighter-highlight="1">$ sed &#039;1!G;h;$!d&#039; t.txt
three
two
one</pre>
<p>其中的 &#8216;1!G;h;$!d&#8217; 可拆解为三个命令</p>
<ul>
<li>1!G —— 只有第一行不执行G命令，将hold space中的内容append回到pattern space</li>
<li>h —— 第一行都执行h命令，将pattern space中的内容拷贝到hold space中</li>
<li>$!d —— 除了最后一行不执行d命令，其它行都执行d命令，删除当前行</li>
</ul>
<p>这个执行序列很难理解，做个图如下大家就明白了：</p>
<p><img decoding="async" loading="lazy" class="aligncenter size-full wp-image-9110" src="https://coolshell.cn/wp-content/uploads/2013/02/sed_demo.jpg" alt="" width="623" height="316" srcset="https://coolshell.cn/wp-content/uploads/2013/02/sed_demo.jpg 623w, https://coolshell.cn/wp-content/uploads/2013/02/sed_demo-300x152.jpg 300w" sizes="(max-width: 623px) 100vw, 623px" /></p>
<p>就先说这么多吧，希望对大家有用。</p>
<p>（全文完）<!--



<p align="center"><a href= target=_blank><img decoding="async" src=""></a></p>





<p align="center"><img decoding="async" src="https://coolshell.cn/wp-content/uploads/2020/03/coolshell.weixin.jpg"> <img decoding="async" loading="lazy" src="https://coolshell.cn/wp-content/uploads/2020/03/coolshell.mini_.jpg" width="300" height="300"> <br />关注CoolShell微信公众账号和微信小程序</p>

 

--></p>
<div style="margin-top: 15px; font-size: 16px;color: #cc0000;">
<p align="center"><strong>（转载本站文章请注明作者和出处 <a href="https://coolshell.cn/">酷 壳 &#8211; CoolShell</a> ，请勿用于任何商业用途）</strong></p>
</div>

<div class="wp_rp_wrap  wp_rp_vertical_m" id="wp_rp_first"><div class="wp_rp_content"><h3 class="related_post_title">相关文章</h3><ul class="related_post wp_rp"><li ><a href="https://coolshell.cn/articles/18360.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2018/05/300x262-150x150.jpg" alt="程序员练级攻略（2018)  与我的专栏" width="150" height="150" /></a><a href="https://coolshell.cn/articles/18360.html" class="wp_rp_title">程序员练级攻略（2018)  与我的专栏</a></li><li ><a href="https://coolshell.cn/articles/17998.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2017/07/systemd-1-150x150.jpeg" alt="Linux PID 1 和 Systemd" width="150" height="150" /></a><a href="https://coolshell.cn/articles/17998.html" class="wp_rp_title">Linux PID 1 和 Systemd</a></li><li ><a href="https://coolshell.cn/articles/12103.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2014/11/tux-fork-150x150.gif" alt="vfork 挂掉的一个问题" width="150" height="150" /></a><a href="https://coolshell.cn/articles/12103.html" class="wp_rp_title">vfork 挂掉的一个问题</a></li><li ><a href="https://coolshell.cn/articles/11847.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2014/08/puzzle-150x150.png" alt="谜题的答案和活动的心得体会" width="150" height="150" /></a><a href="https://coolshell.cn/articles/11847.html" class="wp_rp_title">谜题的答案和活动的心得体会</a></li><li ><a href="https://coolshell.cn/articles/9070.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2013/02/awk-150x150.jpg" alt="AWK 简明教程" width="150" height="150" /></a><a href="https://coolshell.cn/articles/9070.html" class="wp_rp_title">AWK 简明教程</a></li><li ><a href="https://coolshell.cn/articles/8883.html" class="wp_rp_thumbnail"><img src="https://coolshell.cn/wp-content/uploads/2013/01/linux-bash-300x225-150x150.jpg" alt="应该知道的Linux技巧" width="150" height="150" /></a><a href="https://coolshell.cn/articles/8883.html" class="wp_rp_title">应该知道的Linux技巧</a></li></ul></div></div>The post <a href="https://coolshell.cn/articles/9104.html">sed 简明教程</a> first appeared on <a href="https://coolshell.cn">酷 壳 - CoolShell</a>.]]></content:encoded>
					
					<wfw:commentRss>https://coolshell.cn/articles/9104.html/feed</wfw:commentRss>
			<slash:comments>209</slash:comments>
		
		
			</item>
	</channel>
</rss>
