|
5 | 5 | <link href="https://learnbyexample.github.io/atom.xml" rel="self" type="application/atom+xml"/>
|
6 | 6 | <link href="https://learnbyexample.github.io"/>
|
7 | 7 | <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> |
9 | 9 | <id>https://learnbyexample.github.io/atom.xml</id>
|
10 | 10 | <entry xml:lang="en">
|
11 | 11 | <title>Basic examples for the Linux date command</title>
|
12 | 12 | <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> |
14 | 14 | <link rel="alternate" href="https://learnbyexample.github.io/mini/linux-date-command-examples/" type="text/html"/>
|
15 | 15 | <id>https://learnbyexample.github.io/mini/linux-date-command-examples/</id>
|
16 | 16 | <content type="html"><p>I rarely ever use the <code>date</code> command, but when I need it I almost always struggle to get the right incantation. So, I'm just going to record such examples in this blog post (and some good to know features).</p>
|
|
84 | 84 | </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;">&#39;-20 days&#39;
|
85 | 85 | </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
|
86 | 86 | </span></code></pre>
|
| 87 | +<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:</p> |
| 88 | +<pre data-lang="ruby" style="background-color:#f5f5f5;color:#1f1f1f;" class="language-ruby "><code class="language-ruby" data-lang="ruby"><span style="color:#7f8989;"># prev_date variable gets the value from the previous newsletter issue |
| 89 | +</span><span>$ prev_date=</span><span style="color:#d07711;">&#39;2024-02-23&#39; |
| 90 | +</span><span>$ date </span><span style="color:#72ab00;">-</span><span>d </span><span style="color:#d07711;">&quot;$prev_date&quot;&#39; +7 days&#39; </span><span style="color:#72ab00;">+%</span><span style="color:#5597d6;">F |
| 91 | +</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 |
| 92 | +</span></code></pre> |
87 | 93 | <br>
|
88 | 94 | <h2 id="resource-links">Resource links</h2>
|
89 | 95 | <ul>
|
|
0 commit comments