<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Shell on Code Log</title><link>https://codelog.me/en/categories/shell/</link><description>Recent content in Shell on Code Log</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Thu, 23 Jan 2014 23:53:51 +0800</lastBuildDate><atom:link href="https://codelog.me/en/categories/shell/index.xml" rel="self" type="application/rss+xml"/><item><title>sed Quick Start</title><link>https://codelog.me/en/posts/sed-command-quick-reference/</link><pubDate>Thu, 23 Jan 2014 23:53:51 +0800</pubDate><guid>https://codelog.me/en/posts/sed-command-quick-reference/</guid><description>&lt;p&gt;sed and awk are powerful tools for text stream processing. This article provides a quick-start reference for the sed command:&lt;/p&gt;
&lt;h1 id="delete-command"&gt;Delete Command&lt;/h1&gt;
&lt;h3 id="delete-the-nth-line"&gt;Delete the Nth line&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sed 3d abc.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This command deletes the third line.&lt;/p&gt;
&lt;h3 id="delete-every-other-line"&gt;Delete every other line&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	sed &lt;span style="color:#e6db74"&gt;&amp;#39;1~2d&amp;#39;&lt;/span&gt; abc.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	sed &lt;span style="color:#e6db74"&gt;&amp;#39;2~2d&amp;#39;&lt;/span&gt; abc.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The first command deletes odd-numbered lines, and the second deletes even-numbered lines.&lt;/p&gt;
&lt;h3 id="delete-lines-from-n-to-m"&gt;Delete lines from N to M&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	sed &lt;span style="color:#e6db74"&gt;&amp;#39;5,11d&amp;#39;&lt;/span&gt; abc.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Deletes lines 5 through 11.&lt;/p&gt;</description></item></channel></rss>