Skip to content

Commit 1020ee4

Browse files
another example for arithmetic feature
1 parent f44b9e7 commit 1020ee4

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Diff for: atom.xml

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
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-08-08T00:00:00+00:00</updated>
8+
<updated>2024-08-13T00:00:00+00:00</updated>
99
<id>https://learnbyexample.github.io/atom.xml</id>
1010
<entry xml:lang="en">
1111
<title>Basic examples for the Linux date command</title>
1212
<published>2024-07-31T00:00:00+00:00</published>
13-
<updated>2024-08-08T00:00:00+00:00</updated>
13+
<updated>2024-08-13T00:00:00+00:00</updated>
1414
<link rel="alternate" href="https://learnbyexample.github.io/mini/linux-date-command-examples/" type="text/html"/>
1515
<id>https://learnbyexample.github.io/mini/linux-date-command-examples/</id>
1616
<content type="html">&lt;p&gt;I rarely ever use the &lt;code&gt;date&lt;&#x2F;code&gt; command, but when I need it I almost always struggle to get the right incantation. So, I&#x27;m just going to record such examples in this blog post (and some good to know features).&lt;&#x2F;p&gt;
@@ -84,6 +84,12 @@
8484
&lt;&#x2F;span&gt;&lt;span&gt;$ date &lt;&#x2F;span&gt;&lt;span style=&quot;color:#72ab00;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt;I &lt;&#x2F;span&gt;&lt;span style=&quot;color:#72ab00;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d07711;&quot;&gt;&amp;#39;-20 days&amp;#39;
8585
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b3933a;&quot;&gt;2024&lt;&#x2F;span&gt;&lt;span style=&quot;color:#72ab00;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b3933a;&quot;&gt;07&lt;&#x2F;span&gt;&lt;span style=&quot;color:#72ab00;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b3933a;&quot;&gt;13
8686
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
87+
&lt;p&gt;For my &lt;a href=&quot;https:&#x2F;&#x2F;learnbyexample.gumroad.com&#x2F;l&#x2F;learnbyexample-weekly&quot;&gt;learnbyexample weekly&lt;&#x2F;a&gt; newsletter, I use a script to generate a template issue. I use the arithmetic feature as shown below:&lt;&#x2F;p&gt;
88+
&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 style=&quot;color:#7f8989;&quot;&gt;# prev_date variable gets the value from the previous newsletter issue
89+
&lt;&#x2F;span&gt;&lt;span&gt;$ prev_date=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d07711;&quot;&gt;&amp;#39;2024-02-23&amp;#39;
90+
&lt;&#x2F;span&gt;&lt;span&gt;$ date &lt;&#x2F;span&gt;&lt;span style=&quot;color:#72ab00;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;d &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d07711;&quot;&gt;&amp;quot;$prev_date&amp;quot;&amp;#39; +7 days&amp;#39; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#72ab00;&quot;&gt;+%&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt;F
91+
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b3933a;&quot;&gt;2024&lt;&#x2F;span&gt;&lt;span style=&quot;color:#72ab00;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b3933a;&quot;&gt;03&lt;&#x2F;span&gt;&lt;span style=&quot;color:#72ab00;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b3933a;&quot;&gt;01
92+
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
8793
&lt;br&gt;
8894
&lt;h2 id=&quot;resource-links&quot;&gt;Resource links&lt;&#x2F;h2&gt;
8995
&lt;ul&gt;

Diff for: mini/linux-date-command-examples/index.html

+4
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,8 @@
4949
</span><span style=color:#7f8989;># you can also use '20 days ago'
5050
</span><span>$ date </span><span style=color:#72ab00;>-</span><span style=color:#5597d6;>I </span><span style=color:#72ab00;>-</span><span>d </span><span style=color:#d07711;>'-20 days'
5151
</span><span style=color:#b3933a;>2024</span><span style=color:#72ab00;>-</span><span style=color:#b3933a;>07</span><span style=color:#72ab00;>-</span><span style=color:#b3933a;>13
52+
</span></code></pre><p>For my <a href=https://learnbyexample.gumroad.com/l/learnbyexample-weekly>learnbyexample weekly</a> newsletter, I use a script to generate a template issue. I use the arithmetic feature as shown below:<pre class=language-ruby data-lang=ruby style=background-color:#f5f5f5;color:#1f1f1f;><code class=language-ruby data-lang=ruby><span style=color:#7f8989;># prev_date variable gets the value from the previous newsletter issue
53+
</span><span>$ prev_date=</span><span style=color:#d07711;>'2024-02-23'
54+
</span><span>$ date </span><span style=color:#72ab00;>-</span><span>d </span><span style=color:#d07711;>"$prev_date"' +7 days' </span><span style=color:#72ab00;>+%</span><span style=color:#5597d6;>F
55+
</span><span style=color:#b3933a;>2024</span><span style=color:#72ab00;>-</span><span style=color:#b3933a;>03</span><span style=color:#72ab00;>-</span><span style=color:#b3933a;>01
5256
</span></code></pre><br><h2 id=resource-links>Resource links</h2><ul><li><a href=https://www.gnu.org/software/coreutils/manual/coreutils.html#date-invocation>GNU date command manual</a><li><a href="https://unix.stackexchange.com/questions/tagged/date?tab=Votes">Top voted Q&A on unix.stackexchange for the date command tag</a></ul></div><div class=post-footer><div class=post-tags><a href=https://learnbyexample.github.io/tags/linux/>#linux</a><a href=https://learnbyexample.github.io/tags/command-line/>#command-line</a><a href=https://learnbyexample.github.io/tags/date/>#date</a></div><hr color=#e6e6e6><div class=post-nav><p><a class=next href=https://learnbyexample.github.io/mini/cli-text-editing-with-ed/>CLI text editing with ed →</a><br></div><hr color=#e6e6e6><p>📰 Use <a href=https://learnbyexample.github.io/atom.xml>this link</a> for the Atom feed. <br> ✅ Follow me on <a href=https://twitter.com/learn_byexample>Twitter</a>, <a href=https://github.com/learnbyexample>GitHub</a> and <a href=https://www.youtube.com/c/learnbyexample42>Youtube</a> for interesting tech nuggets. <br> 📧 Subscribe to <a href=https://learnbyexample.gumroad.com/l/learnbyexample-weekly>learnbyexample weekly</a> for programming resources, tips, tools, free ebooks and more (free newsletter, delivered every Friday).<hr color=#e6e6e6></div></article></div></main></div><script src=https://learnbyexample.github.io/even.js></script>

Diff for: sitemap.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
</url>
145145
<url>
146146
<loc>https://learnbyexample.github.io/mini/linux-date-command-examples/</loc>
147-
<lastmod>2024-08-08</lastmod>
147+
<lastmod>2024-08-13</lastmod>
148148
</url>
149149
<url>
150150
<loc>https://learnbyexample.github.io/mini/perl-oneliner-articles/</loc>

0 commit comments

Comments
 (0)