<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>time &amp;mdash; Paul Sutton</title>
    <link>https://personaljournal.ca/paulsutton/tag:time</link>
    <description>Personal Blog</description>
    <pubDate>Tue, 05 May 2026 16:33:21 +0000</pubDate>
    <item>
      <title>Bash Scripting 20 - Write date and data a file</title>
      <link>https://personaljournal.ca/paulsutton/bash-scripting-20-write-date-and-data-a-file</link>
      <description>&lt;![CDATA[Bash Scripting 20 - Write date and data a file&#xA;&#xA;So following on from the previous scripts,  it may be useful to record both the date and some data associated with that date to a file. &#xA;&#xA;I have found out how to do this, but also tidied my script up, removed some unneeded code (quite  a lot) and this should work.&#xA;&#xA;echo &#34;date&#34; &#34;data&#34; # for reference, not written to file &#xA;for ((i = 0 ; i &lt; 10 ; i++)); do&#xA;    echo $(date), $((RANDOM % 20)) # echo to screen (stdout)&#xA;    echo $(date), $((RANDOM % 20))   log3.csv&#xA;done&#xA;&#xA;Produces&#xA;date data&#xA;Fri 18 Apr 12:48:16 BST 2025, 0&#xA;Fri 18 Apr 12:48:16 BST 2025, 15&#xA;Fri 18 Apr 12:48:16 BST 2025, 13&#xA;Fri 18 Apr 12:48:16 BST 2025, 6&#xA;Fri 18 Apr 12:48:16 BST 2025, 6&#xA;Fri 18 Apr 12:48:16 BST 2025, 13&#xA;Fri 18 Apr 12:48:16 BST 2025, 18&#xA;Fri 18 Apr 12:48:16 BST 2025, 5&#xA;Fri 18 Apr 12:48:16 BST 2025, 3&#xA;Fri 18 Apr 12:48:16 BST 2025, 14&#xA;&#xA;Which is fine, but we can refine the date output so it is shorter with&#xA;&#xA;date &#34;+DATE: %D TIME: %T&#34;&#xA;&#xA;  date &#34;+%D&#34;   display date no label&#xA;  date &#34;+%T&#34;  display tine no label &#xA;If we want this in a csv file it may help to add a comma&#xA;&#xA;date &#34;+DATE: %D, TIME: %T&#34;&#xA;Remove the labels DATE: &amp; TIME:&#xA;date &#34;+ %D, %T&#34;&#xA;Produces&#xA;&#xA;date &#34;+ %D, %T&#34;&#xA; 04/20/25, 14:58:19&#xA;&#xA;My final entry, in the script run by cron, at least as far as time and date is concerned&#xA;&#xA;echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l Paignton -a false)     weather.csv&#xA;As this sends the output to weather.csv, If we remove the redirect it will go to stout (standard output)   we can just run the following on the terminal &#39;as is&#39;&#xA;&#xA;echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l Paignton -a false)&#xA;This you should end up with&#xA;&#xA;04/29/25, 15:44:14, Weather in Paignton: 16 °C - UVI: 5.91 - Wind: 0.89 m/s NNE - Humidity: 75% - Pressure: 1024 hPa&#xA;&#xA;I have just copied and pasted the line in to the terminal and removed the     weather.csv as that appends the csv file with the data.&#xA;&#xA;As we all have different use cases, this solution is fine for me, I can adjust to suit further.&#xA;This is far more useful for a CSV file, especially if you want to load the data in to a spreadsheet. &#xA;&#xA;See fourth link below for full details.&#xA;Sources of help&#xA;&#xA;https://stackoverflow.com/questions/40175868/how-to-create-csv-file-using-shell-script&#xA;https://stackoverflow.com/questions/1194882/how-to-generate-random-number-in-bash&#xA;https://linuxhandbook.com/bash-loops/&#xA;https://stackoverflow.com/questions/25242626/bash-redirect-output-to-log-file-with-day-date-in-the-name&#xA;https://phoenixnap.com/kb/linux-date-command&#xA;&#xA;Tags&#xA;&#xA;#Bash,#Bashscripting,#BashScripting,#Files,#Write,#Data,#Time,#Data&#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Bash Scripting 20 – Write date and data a file</p>

<p>So following on from the previous scripts,  it may be useful to record both the date and some data associated with that date to a file.</p>

<p>I have found out how to do this, but also tidied my script up, removed some unneeded code (quite  a lot) and this should work.</p>

<pre><code class="language-bash">echo &#34;date&#34; &#34;data&#34; # for reference, not written to file 
for ((i = 0 ; i &lt; 10 ; i++)); do
    echo $(date), $((RANDOM % 20)) # echo to screen (stdout)
    echo $(date), $((RANDOM % 20)) &gt; log3.csv
done
</code></pre>

<p>Produces</p>

<pre><code>date data
Fri 18 Apr 12:48:16 BST 2025, 0
Fri 18 Apr 12:48:16 BST 2025, 15
Fri 18 Apr 12:48:16 BST 2025, 13
Fri 18 Apr 12:48:16 BST 2025, 6
Fri 18 Apr 12:48:16 BST 2025, 6
Fri 18 Apr 12:48:16 BST 2025, 13
Fri 18 Apr 12:48:16 BST 2025, 18
Fri 18 Apr 12:48:16 BST 2025, 5
Fri 18 Apr 12:48:16 BST 2025, 3
Fri 18 Apr 12:48:16 BST 2025, 14

</code></pre>

<p>Which is fine, but we can refine the date output so it is shorter with</p>

<pre><code>date &#34;+DATE: %D TIME: %T&#34;
</code></pre>

<pre><code>  date &#34;+%D&#34;   display date no label
  date &#34;+%T&#34;  display tine no label 
</code></pre>

<p>If we want this in a csv file it may help to add a comma</p>

<pre><code>date &#34;+DATE: %D, TIME: %T&#34;
</code></pre>

<p>Remove the labels DATE: &amp; TIME:</p>

<pre><code>date &#34;+ %D, %T&#34;
</code></pre>

<p>Produces</p>

<pre><code>date &#34;+ %D, %T&#34;
 04/20/25, 14:58:19
</code></pre>

<p>My final entry, in the script run by cron, at least as far as time and date is concerned</p>

<pre><code>echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l Paignton -a false) &gt;&gt; weather.csv
</code></pre>

<p>As this sends the output to weather.csv, If we remove the redirect it will go to stout (standard output)   we can just run the following on the terminal &#39;as is&#39;</p>

<pre><code>echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l Paignton -a false)
</code></pre>

<p>This you should end up with</p>

<pre><code>04/29/25, 15:44:14, Weather in Paignton: 16 °C - UVI: 5.91 - Wind: 0.89 m/s NNE - Humidity: 75% - Pressure: 1024 hPa

</code></pre>

<p>I have just copied and pasted the line in to the terminal and removed the &gt;&gt; weather.csv as that appends the csv file with the data.</p>

<p>As we all have different use cases, this solution is fine for me, I can adjust to suit further.
This is far more useful for a CSV file, especially if you want to load the data in to a spreadsheet.</p>

<p>See fourth link below for full details.
* Sources of help</p>

<pre><code>https://stackoverflow.com/questions/40175868/how-to-create-csv-file-using-shell-script
https://stackoverflow.com/questions/1194882/how-to-generate-random-number-in-bash
https://linuxhandbook.com/bash-loops/
https://stackoverflow.com/questions/25242626/bash-redirect-output-to-log-file-with-day-date-in-the-name
https://phoenixnap.com/kb/linux-date-command
</code></pre>

<p><strong>Tags</strong></p>

<p><a href="/paulsutton/tag:Bash" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Bash</span></a>,<a href="/paulsutton/tag:Bashscripting" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Bashscripting</span></a>,<a href="/paulsutton/tag:BashScripting" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">BashScripting</span></a>,<a href="/paulsutton/tag:Files" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Files</span></a>,<a href="/paulsutton/tag:Write" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Write</span></a>,<a href="/paulsutton/tag:Data" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Data</span></a>,<a href="/paulsutton/tag:Time" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Time</span></a>,<a href="/paulsutton/tag:Data" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Data</span></a></p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/bash-scripting-20-write-date-and-data-a-file</guid>
      <pubDate>Fri, 25 Apr 2025 06:30:00 +0000</pubDate>
    </item>
    <item>
      <title>How far does light travel?</title>
      <link>https://personaljournal.ca/paulsutton/how-far-does-light-travel</link>
      <description>&lt;![CDATA[How far does light travel?&#xA;&#xA;Interesting video from NASA on how far light travels in a given period of time. &#xA;&#xA;How far does light travel?&#xA;&#xA;Links&#xA;&#xA;Original post&#xA;Science Forums&#xA;&#xA;Happy do discuss further on Mastodon, my id is : @zleap@qoto.org&#xA;&#xA;Tags&#xA;&#xA;#NASA,#Light,#Time,#Distance&#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>How far does light travel?</p>

<p>Interesting video from NASA on how far light travels in a given period of time.</p>
<ul><li><a href="https://social.beachcom.org/system/media_attachments/files/109/610/150/829/649/746/original/67dcd78ffcba5244.mp4" rel="nofollow">How far does light travel?</a></li></ul>

<p><strong>Links</strong></p>
<ul><li><a href="https://social.beachcom.org/@nasa" rel="nofollow">Original post</a></li>
<li><a href="https://www.scienceforums.net" rel="nofollow">Science Forums</a></li></ul>

<p>Happy do discuss further on Mastodon, my id is : <a href="https://personaljournal.ca/@/zleap@qoto.org" class="u-url mention" rel="nofollow">@<span>zleap@qoto.org</span></a></p>

<p><strong>Tags</strong></p>

<p><a href="/paulsutton/tag:NASA" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">NASA</span></a>,<a href="/paulsutton/tag:Light" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Light</span></a>,<a href="/paulsutton/tag:Time" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Time</span></a>,<a href="/paulsutton/tag:Distance" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Distance</span></a></p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/how-far-does-light-travel</guid>
      <pubDate>Sun, 08 Jan 2023 07:30:00 +0000</pubDate>
    </item>
  </channel>
</rss>