Skip to content

Commit 5383f97

Browse files
added another use case for ed
1 parent 59d121f commit 5383f97

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Diff for: atom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link href="https://learnbyexample.github.io/atom.xml" rel="self" type="application/atom+xml"/>
66
<link href="https://learnbyexample.github.io"/>
77
<generator uri="https://www.getzola.org/">Zola</generator>
8-
<updated>2024-02-26T00:00:00+00:00</updated>
8+
<updated>2024-03-28T00:00:00+00:00</updated>
99
<id>https://learnbyexample.github.io/atom.xml</id>
1010
<entry xml:lang="en">
1111
<title>Ruby One-Liners Guide book announcement</title>
@@ -379,7 +379,7 @@
379379
<entry xml:lang="en">
380380
<title>CLI text editing with ed</title>
381381
<published>2023-10-17T00:00:00+00:00</published>
382-
<updated>2023-10-17T00:00:00+00:00</updated>
382+
<updated>2024-03-28T00:00:00+00:00</updated>
383383
<link rel="alternate" href="https://learnbyexample.github.io/mini/cli-text-editing-with-ed/" type="text/html"/>
384384
<id>https://learnbyexample.github.io/mini/cli-text-editing-with-ed/</id>
385385
<content type="html">&lt;p&gt;I&#x27;m finally writing a post on the &lt;code&gt;ed&lt;&#x2F;code&gt; command. And I&#x27;m keeping it short so that I&#x27;ll actually publish the post. The examples presented below will be easier to understand for those already familiar with Vim and &lt;code&gt;sed&lt;&#x2F;code&gt;. See the links at the end for learning resources.&lt;&#x2F;p&gt;
@@ -429,7 +429,7 @@
429429
&lt;&#x2F;span&gt;&lt;span&gt;fig
430430
&lt;&#x2F;span&gt;&lt;span&gt;mango
431431
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
432-
&lt;p&gt;Here&#x27;s the &lt;a href=&quot;https:&#x2F;&#x2F;stackoverflow.com&#x2F;q&#x2F;67031062&#x2F;4082052&quot;&gt;stackoverflow link&lt;&#x2F;a&gt; that inspired the above examples. See &lt;a href=&quot;https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;75222984&#x2F;4082052&quot;&gt;this stackoverflow answer&lt;&#x2F;a&gt; for more examples of moving lines. See &lt;a href=&quot;https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;48840851&#x2F;4082052&quot;&gt;this one&lt;&#x2F;a&gt; to learn how to copy a particular line to the end of the file.&lt;&#x2F;p&gt;
432+
&lt;p&gt;Here&#x27;s the &lt;a href=&quot;https:&#x2F;&#x2F;stackoverflow.com&#x2F;q&#x2F;67031062&#x2F;4082052&quot;&gt;stackoverflow link&lt;&#x2F;a&gt; that inspired the above examples. See &lt;a href=&quot;https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;75222984&#x2F;4082052&quot;&gt;this stackoverflow answer&lt;&#x2F;a&gt; for more examples of moving lines. See &lt;a href=&quot;https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;48840851&#x2F;4082052&quot;&gt;this one&lt;&#x2F;a&gt; to learn how to copy a particular line to the end of the file. See &lt;a href=&quot;https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;a&#x2F;759710&#x2F;109046&quot;&gt;this unix.stackexchange answer&lt;&#x2F;a&gt; for an example of moving a range of lines, where the same regex matches both the starting and ending lines.&lt;&#x2F;p&gt;
433433
&lt;h2 id=&quot;negative-addressing&quot;&gt;Negative addressing&lt;&#x2F;h2&gt;
434434
&lt;p&gt;There are plenty of &lt;a href=&quot;https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;learn_gnused&#x2F;selective-editing.html&quot;&gt;addressing features&lt;&#x2F;a&gt; provided by the &lt;code&gt;GNU sed&lt;&#x2F;code&gt; command, but negative addressing isn&#x27;t one. Here&#x27;s an example of deleting the last but second line using &lt;code&gt;ed&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
435435
&lt;pre data-lang=&quot;ruby&quot; style=&quot;background-color:#f5f5f5;color:#1f1f1f;&quot; class=&quot;language-ruby &quot;&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span&gt;$ cat colors.txt

Diff for: mini/cli-text-editing-with-ed/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</span><span>cherry
3434
</span><span>fig
3535
</span><span>mango
36-
</span></code></pre><p>Here's the <a href=https://stackoverflow.com/q/67031062/4082052>stackoverflow link</a> that inspired the above examples. See <a href=https://stackoverflow.com/a/75222984/4082052>this stackoverflow answer</a> for more examples of moving lines. See <a href=https://stackoverflow.com/a/48840851/4082052>this one</a> to learn how to copy a particular line to the end of the file.<h2 id=negative-addressing>Negative addressing</h2><p>There are plenty of <a href=https://learnbyexample.github.io/learn_gnused/selective-editing.html>addressing features</a> provided by the <code>GNU sed</code> command, but negative addressing isn't one. Here's an example of deleting the last but second line using <code>ed</code>:<pre class=language-ruby data-lang=ruby style=background-color:#f5f5f5;color:#1f1f1f;><code class=language-ruby data-lang=ruby><span>$ cat colors.txt
36+
</span></code></pre><p>Here's the <a href=https://stackoverflow.com/q/67031062/4082052>stackoverflow link</a> that inspired the above examples. See <a href=https://stackoverflow.com/a/75222984/4082052>this stackoverflow answer</a> for more examples of moving lines. See <a href=https://stackoverflow.com/a/48840851/4082052>this one</a> to learn how to copy a particular line to the end of the file. See <a href=https://unix.stackexchange.com/a/759710/109046>this unix.stackexchange answer</a> for an example of moving a range of lines, where the same regex matches both the starting and ending lines.<h2 id=negative-addressing>Negative addressing</h2><p>There are plenty of <a href=https://learnbyexample.github.io/learn_gnused/selective-editing.html>addressing features</a> provided by the <code>GNU sed</code> command, but negative addressing isn't one. Here's an example of deleting the last but second line using <code>ed</code>:<pre class=language-ruby data-lang=ruby style=background-color:#f5f5f5;color:#1f1f1f;><code class=language-ruby data-lang=ruby><span>$ cat colors.txt
3737
</span><span>red
3838
</span><span>green
3939
</span><span>blue

Diff for: sitemap.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
</url>
113113
<url>
114114
<loc>https://learnbyexample.github.io/mini/cli-text-editing-with-ed/</loc>
115-
<lastmod>2023-10-17</lastmod>
115+
<lastmod>2024-03-28</lastmod>
116116
</url>
117117
<url>
118118
<loc>https://learnbyexample.github.io/mini/debug-woes-1/</loc>

0 commit comments

Comments
 (0)