<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>data &amp;mdash; Paul Sutton</title>
    <link>https://personaljournal.ca/paulsutton/tag:data</link>
    <description>Personal Blog</description>
    <pubDate>Tue, 05 May 2026 14:56:41 +0000</pubDate>
    <item>
      <title>Weather logging data sets</title>
      <link>https://personaljournal.ca/paulsutton/weather-logging-data-sets</link>
      <description>&lt;![CDATA[Weather logging data sets&#xA;&#xA;I am going to just run this script at weekends,  so all the data is uploaded as soon as I can after collection.    Once transferred to the gopher server, the data is deleted from the Raspberry Pi.&#xA;&#xA;gopher://gopher.vern.cc/1/~zleap&#xA;&#xA;      [42] Weather data June 9th 2025&#xA;      [43] Weather data June 10th 2025&#xA;      [44] Weather data July 5th 2025&#xA;      [45] Weather data July 6th 2025&#xA;      [46] Weather data July 12th 2025&#xA;      [47] Weather data July 13th 2025&#xA;&#xA;As previously stated,   all this is provided &#39;as is&#39;.   I have no intention, at this present time,  of sharing by other means.&#xA;&#xA;Tags&#xA;&#xA;#Data,#Science,#Weather,&#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>Weather logging data sets</p>

<p>I am going to just run this script at weekends,  so all the data is uploaded as soon as I can after collection.    Once transferred to the gopher server, the data is deleted from the Raspberry Pi.</p>

<p>gopher://gopher.vern.cc/1/~zleap</p>

<pre><code>      [42] Weather data June 9th 2025
      [43] Weather data June 10th 2025
      [44] Weather data July 5th 2025
      [45] Weather data July 6th 2025
      [46] Weather data July 12th 2025
      [47] Weather data July 13th 2025

</code></pre>

<p>As previously stated,   all this is provided &#39;as is&#39;.   I have no intention, at this present time,  of sharing by other means.</p>

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

<p><a href="/paulsutton/tag:Data" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Data</span></a>,<a href="/paulsutton/tag:Science" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Science</span></a>,<a href="/paulsutton/tag:Weather" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Weather</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/weather-logging-data-sets</guid>
      <pubDate>Wed, 23 Jul 2025 06:00:00 +0000</pubDate>
    </item>
    <item>
      <title>Weather logging</title>
      <link>https://personaljournal.ca/paulsutton/weather-logging</link>
      <description>&lt;![CDATA[Weather logging&#xA;&#xA;So been experimenting with some of the options for ansiweather, partly as schools   need to teach data logging as part of the national curriculum computing,  however not all schools have the kit required.&#xA;&#xA;As I have this running on a Raspberry Pi,  I thought it may be possible to set one up to log just the location and temperature.  &#xA;&#xA;ansiweather -l paignton -p false -h false  -w false -i false   temponly.txt&#xA;&#xA;so the above will display the location and temperature,   but exclude pressure, humidity, wind and UV index.&#xA;&#xA;now=$(date +&#34;%m%d%Y&#34;)&#xA;echo &#34;Filename : /nas/backup$weather.csv&#34;&#xA;echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l Paignton -a false)     weather$now.csv&#xA;&#xA;Control what is sent to stdout.&#xA;&#xA;now=$(date +&#34;%m%d%Y&#34;)&#xA;echo &#34;Filename : /nas/backup$weather.csv&#34;&#xA;echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l torquay -p false -h false  -w false -i false)     torquay$now.csv&#xA;&#xA;Final script&#xA;&#xA;now=$(date +&#34;%m%d%Y&#34;)&#xA;echo &#34;Filename : /nas/backup$weather.csv&#34;&#xA;echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l torquay -p false -h false  -w false -i false)     torquay$now.csv&#xA;&#xA;Tags&#xA;&#xA;#Bash,#BashScripting,#Logging,#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>Weather logging</p>

<p>So been experimenting with some of the options for ansiweather, partly as schools   need to teach data logging as part of the national curriculum computing,  however not all schools have the kit required.</p>

<p>As I have this running on a Raspberry Pi,  I thought it may be possible to set one up to log just the location and temperature.</p>

<pre><code>ansiweather -l paignton -p false -h false  -w false -i false &gt;temponly.txt
</code></pre>

<p>so the above will display the location and temperature,   but exclude pressure, humidity, wind and UV index.</p>

<pre><code>now=$(date +&#34;%m_%d_%Y&#34;)
echo &#34;Filename : /nas/backup_$weather.csv&#34;
echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l Paignton -a false) &gt;&gt; weather_$now.csv
</code></pre>

<p>Control what is sent to stdout.</p>

<pre><code>now=$(date +&#34;%m_%d_%Y&#34;)
echo &#34;Filename : /nas/backup_$weather.csv&#34;
echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l torquay -p false -h false  -w false -i false) &gt;&gt; torquay_$now.csv
</code></pre>

<p>Final script</p>

<pre><code>now=$(date +&#34;%m_%d_%Y&#34;)
echo &#34;Filename : /nas/backup_$weather.csv&#34;
echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l torquay -p false -h false  -w false -i false) &gt;&gt; torquay_$now.csv
</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:Logging" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Logging</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/weather-logging</guid>
      <pubDate>Fri, 18 Jul 2025 06:52:59 +0000</pubDate>
    </item>
    <item>
      <title>Logging the weather</title>
      <link>https://personaljournal.ca/paulsutton/logging-the-weather</link>
      <description>&lt;![CDATA[Logging the weather&#xA;&#xA;I have modified the script that runs every 10 minutes to record the output from the ansiweather utility,   This still saves the output to a file but adds the current date to the file name.&#xA;&#xA;now=$(date +&#34;%m%d%Y&#34;)&#xA;echo &#34;Filename : /nas/backup$weather.csv&#34;&#xA;echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l Paignton -a false)     weather$now.csv&#xA;&#xA;So the output looks like&#xA;&#xA; Humidity: 71% - Pressure: 1023 hPa&#xA;06/09/25, 14:20:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 1.79 m/s WSW - Humidity: 69% - Pressure: 1024 hPa&#xA;06/09/25, 14:30:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 2.24 m/s SW - Humidity: 70% - Pressure: 1023 hPa&#xA;06/09/25, 14:40:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 3.13 m/s W - Humidity: 69% - Pressure: 1023 hPa&#xA;06/09/25, 14:50:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 1.79 m/s SW - Humidity: 69% - Pressure: 1023 hPa&#xA;06/09/25, 15:00:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 1.79 m/s WSW - Humidity: 71% - Pressure: 1023 hPa&#xA;06/09/25, 15:10:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 1.34 m/s SSW - Humidity: 71% - Pressure: 1024 hPa&#xA;&#xA;As this runs on a headless pi4,  I can login and copy the data files locally before uploading to my gopherspace (Look it up) &#xA;&#xA;gopher://vern.cc/1/~zleap&#xA;&#xA;Tags&#xA;&#xA;#Bash,#BashScripting,#Data,#Logging,#Gopher,#RaspberryPi,&#xA;Weather&#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>Logging the weather</p>

<p>I have modified the script that runs every 10 minutes to record the output from the ansiweather utility,   This still saves the output to a file but adds the current date to the file name.</p>

<pre><code class="language-bash">now=$(date +&#34;%m_%d_%Y&#34;)
echo &#34;Filename : /nas/backup_$weather.csv&#34;
echo $(date &#34;+ %D, %T&#34;), $(ansiweather -l Paignton -a false) &gt;&gt; weather_$now.csv
</code></pre>

<p>So the output looks like</p>

<pre><code> Humidity: 71% - Pressure: 1023 hPa
06/09/25, 14:20:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 1.79 m/s WSW - Humidity: 69% - Pressure: 1024 hPa
06/09/25, 14:30:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 2.24 m/s SW - Humidity: 70% - Pressure: 1023 hPa
06/09/25, 14:40:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 3.13 m/s W - Humidity: 69% - Pressure: 1023 hPa
06/09/25, 14:50:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 1.79 m/s SW - Humidity: 69% - Pressure: 1023 hPa
06/09/25, 15:00:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 1.79 m/s WSW - Humidity: 71% - Pressure: 1023 hPa
06/09/25, 15:10:01, Weather in Paignton: 18 °C - UVI: 7.03 - Wind: 1.34 m/s SSW - Humidity: 71% - Pressure: 1024 hPa
</code></pre>

<p>As this runs on a headless pi4,  I can login and copy the data files locally before uploading to my gopherspace (<strong>Look it up</strong>)</p>

<pre><code>gopher://vern.cc/1/~zleap
</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:Data" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Data</span></a>,<a href="/paulsutton/tag:Logging" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Logging</span></a>,<a href="/paulsutton/tag:Gopher" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Gopher</span></a>,<a href="/paulsutton/tag:RaspberryPi" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">RaspberryPi</span></a>,
<a href="/paulsutton/tag:Weather" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Weather</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/logging-the-weather</guid>
      <pubDate>Mon, 09 Jun 2025 14:23:22 +0000</pubDate>
    </item>
    <item>
      <title>Big Tech and AI Training</title>
      <link>https://personaljournal.ca/paulsutton/big-tech-and-ai-training</link>
      <description>&lt;![CDATA[Big Tech and AI Training&#xA;&#xA;Meta, Facebook, and Instagram AI is coming for EU data — Here&#39;s what you need to know (and how to opt out)&#xA;&#xA;Opt out of AI data training by big techI &#xA;&#xA;This will happen from 27th May, you need to opt out or your data will be used to train their AI.&#xA;&#xA;Join the Fediverse&#xA;&#xA;Tags&#xA;&#xA;#BigTech,#Meta,#Facebook,#Instagram,#WhatsApp,#GDPR,#Data.#Fediverse,#Mastodon,#PixelFed,#Matrix,#XMPP,#ActivityPub,#Replacement,#Privacy,#Rights,#DataProtection,#EU,#UK&#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>Big Tech and AI Training</p>

<p>Meta, Facebook, and Instagram AI is coming for EU data — Here&#39;s what you need to know (and how to opt out)</p>
<ul><li><a href="https://www.windowscentral.com/microsoft/meta-facebook-and-instagram-ai-is-coming-for-eu-data-heres-what-you-need-to-know-and-how-to-opt-out" rel="nofollow">Opt out of AI data training by big techI </a></li></ul>

<p>This will happen from 27th May, you need to opt out or your data will be used to train their AI.</p>
<ul><li><a href="https://jointhefediverse.net/?lang=en-us" rel="nofollow">Join the Fediverse</a></li></ul>

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

<p><a href="/paulsutton/tag:BigTech" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">BigTech</span></a>,<a href="/paulsutton/tag:Meta" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Meta</span></a>,<a href="/paulsutton/tag:Facebook" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Facebook</span></a>,<a href="/paulsutton/tag:Instagram" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Instagram</span></a>,<a href="/paulsutton/tag:WhatsApp" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">WhatsApp</span></a>,<a href="/paulsutton/tag:GDPR" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">GDPR</span></a>,<a href="/paulsutton/tag:Data" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Data</span></a>.<a href="/paulsutton/tag:Fediverse" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Fediverse</span></a>,<a href="/paulsutton/tag:Mastodon" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Mastodon</span></a>,<a href="/paulsutton/tag:PixelFed" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">PixelFed</span></a>,<a href="/paulsutton/tag:Matrix" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Matrix</span></a>,<a href="/paulsutton/tag:XMPP" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">XMPP</span></a>,<a href="/paulsutton/tag:ActivityPub" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ActivityPub</span></a>,<a href="/paulsutton/tag:Replacement" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Replacement</span></a>,<a href="/paulsutton/tag:Privacy" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Privacy</span></a>,<a href="/paulsutton/tag:Rights" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Rights</span></a>,<a href="/paulsutton/tag:DataProtection" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">DataProtection</span></a>,<a href="/paulsutton/tag:EU" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">EU</span></a>,<a href="/paulsutton/tag:UK" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">UK</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/big-tech-and-ai-training</guid>
      <pubDate>Tue, 06 May 2025 06:07:56 +0000</pubDate>
    </item>
    <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>Bash scripting 18 – Using data files 4</title>
      <link>https://personaljournal.ca/paulsutton/bash-scripting-18-using-data-files-4</link>
      <description>&lt;![CDATA[Bash scripting 18 – Using data files 4&#xA;&#xA;So, carrying on from the previous article(s).  &#xA;&#xA;Using the guide at [2].  We can set a few labels up so the graph looks nicer.&#xA;&#xA;Once in gnu plot you can issue commands, then run replot to redraw the graph. &#xA;&#xA;gnuplot  plot &#39;log.csv&#39;&#xA;gnuplot  plot &#39;log.csv&#39; with lines&#xA;gnuplot  set title &#39;Example Plot&#39;&#xA;gnuplot  set xlabel &#39;x axis&#39;&#xA;gnuplot  set ylabel &#39;y axis&#39; &#xA;gnuplot  replot&#xA;gnuplot  set key top right&#xA;gnuplot  replot&#xA;&#xA;By running replot we can see the results are what we want before carrying on. &#xA;&#xA;All this is just a small sample of what can be done,  I will explore more on this once I have some useful, rather than randomly generated data to plot or do things with.&#xA;&#xA;References&#xA;&#xA;1 gnuplot&#xA;2 gnuplot examples&#xA;&#xA;Chat&#xA;&#xA;I am on the Devon and Cornwall Linux user group mailing list and also their matrix channel as zleap, it is better to ask there, that way others can answer too.&#xA;&#xA;Tags&#xA;&#xA;#Bash,#Bashscripting,#BashScripting,#Files,#UsingDataFiles,#Data,#gnuplot,#graphs&#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 18 – Using data files 4</p>

<p>So, carrying on from the previous article(s).</p>

<p>Using the guide at [2].  We can set a few labels up so the graph looks nicer.</p>

<p>Once in gnu plot you can issue commands, then run replot to redraw the graph.</p>

<pre><code>gnuplot&gt; plot &#39;log.csv&#39;
gnuplot&gt; plot &#39;log.csv&#39; with lines
gnuplot&gt; set title &#39;Example Plot&#39;
gnuplot&gt; set xlabel &#39;x axis&#39;
gnuplot&gt; set ylabel &#39;y axis&#39; 
gnuplot&gt; replot
gnuplot&gt; set key top right
gnuplot&gt; replot

</code></pre>

<p>By running <em>replot</em> we can see the results are what we want before carrying on.</p>

<p>All this is just a small sample of what can be done,  I will explore more on this once I have some useful, rather than randomly generated data to plot or do things with.</p>

<p><strong>References</strong></p>

<p>1 <a href="https://www.gnuplot.info" rel="nofollow">gnuplot</a>
2 <a href="https://alvinalexander.com/technology/gnuplot-charts-graphs-examples/#4" rel="nofollow">gnuplot examples</a></p>

<p><strong>Chat</strong></p>

<p>I am on the <a href="https://www.dcglug.org.uk/" rel="nofollow">Devon and Cornwall Linux user group</a> mailing list and also their <a href="https://matrix.to/#/%23dcglug:matrix.org" rel="nofollow">matrix channel</a> as zleap, it is better to ask there, that way others can answer too.</p>

<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:UsingDataFiles" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">UsingDataFiles</span></a>,<a href="/paulsutton/tag:Data" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Data</span></a>,<a href="/paulsutton/tag:gnuplot" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">gnuplot</span></a>,<a href="/paulsutton/tag:graphs" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">graphs</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-18-using-data-files-4</guid>
      <pubDate>Sun, 20 Apr 2025 06:00:00 +0000</pubDate>
    </item>
    <item>
      <title>Bash scripting 17 – Using data files 3</title>
      <link>https://personaljournal.ca/paulsutton/bash-scripting-17-using-data-files-3</link>
      <description>&lt;![CDATA[Bash scripting 17 – Using data files 3&#xA;&#xA;So, carrying on from the previous article(s).  I am going to be using gnuplot to display the data.   I found a useful site, that has examples of how to use the software,  from basic to more advanced examples. &#xA;&#xA;Notes: As with bash gnu plot has command history, so you can use arrow keys to move up / down between previously entered commands.&#xA;&#xA;Based on the information at [2] we can produce a very basic plot of what is in log.csv&#xA;&#xA;Load GNUPlot&#xA;&#xA;gnuplot&#xA;and enter&#xA;&#xA;plot &#39;log.csv&#39;&#xA;This example isn&#39;t all that good really, but it at least produces some output.  I have modified one of the examples further down that page&#xA;&#xA;plot &#39;log.csv&#39; using 1:2 with lines, &#39;log.csv&#39; using 1:2 with lines&#xA; So the following data set&#xA;&#xA;0, 1&#xA;1, 10&#xA;2, 10&#xA;3, 7&#xA;4, 2&#xA;5, 1&#xA;6, 15&#xA;7, 0&#xA;8, 19&#xA;9, 3&#xA;&#xA;Should produce something like&#xA;&#xA;gnuplot 1&#xA;&#xA;Adding extra columns&#xA;&#xA;We probably need more than two columns.  This is easily done by modifying the loop in the script gendata1.csv.   It is a good idea to copy this to a new script so it keeps the original as is&#xA;&#xA;cp gendata1.sh gendata2.sh&#xA;As gendata1.sh has write permissions, these will be preserved in the new copy of the file.   We can now edit  gendata2.sh&#xA;&#xA;echo &#34;number&#34; &#34;data&#34; # for reference, not written to file &#xA;for ((i = 0 ; i &lt; 10 ; i++)); do&#xA;    echo $i, $((RANDOM % 20)), $((RANDOM % 20)) # echo to screen (stdout)&#xA;&#x9;echo $i, $((RANDOM % 20)), $((RANDOM % 20))     log.csv # write to file&#xA;    #write_csv $(($i, $RANDOM % 10))&#xA;done&#xA;So all we are doing here is adding in, note the comma&#xA;&#xA;, $((RANDOM % 20))&#xA;&#xA;As the only difference between the lines&#xA;&#xA;echo $i, $((RANDOM % 20)), $((RANDOM % 20)) # echo to screen (stdout)&#xA;echo $i, $((RANDOM % 20)), $((RANDOM % 20))     log.csv # write to file&#xA;Is that the first line, writes to the screen, it may be better to test the script out, check it does what you want, then modify the line that writes to a file once you are happy.&#xA;&#xA;References&#xA;&#xA;1 gnuplot&#xA;2 gnuplot examples&#xA;GNU Plot and LaTeX, included for reference&#xA;&#xA;Chat&#xA;&#xA;I am on the Devon and Cornwall Linux user group mailing list and also their matrix channel as zleap, it is better to ask there, that way others can answer too.&#xA;&#xA;Tags&#xA;&#xA;#Bash,#Bashscripting,#Files,#UsingDataFiles,#Data,#gnuplot,#graphs,#BashScripting&#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 17 – Using data files 3</p>

<p>So, carrying on from the previous article(s).  I am going to be using gnuplot to display the data.   I found a useful site, that has examples of how to use the software,  from basic to more advanced examples.</p>

<p>Notes: As with bash gnu plot has command history, so you can use arrow keys to move up / down between previously entered commands.</p>

<p>Based on the information at [2] we can produce a very basic plot of what is in log.csv</p>

<p>Load GNUPlot</p>

<pre><code class="language-bash">gnuplot
</code></pre>

<p>and enter</p>

<pre><code class="language-gnuplot">plot &#39;log.csv&#39;
</code></pre>

<p>This example isn&#39;t all that good really, but it at least produces some output.  I have modified one of the examples further down that page</p>

<pre><code class="language-gnuplot">plot &#39;log.csv&#39; using 1:2 with lines, &#39;log.csv&#39; using 1:2 with lines
</code></pre>

<p> So the following data set</p>

<pre><code class="language-text">0, 1
1, 10
2, 10
3, 7
4, 2
5, 1
6, 15
7, 0
8, 19
9, 3

</code></pre>

<p>Should produce something like</p>

<p><img src="https://salsa.debian.org/zleap-guest/blog-media/-/raw/master/gnuplot1.png" alt="gnuplot 1"></p>

<p>Adding extra columns</p>

<p>We probably need more than two columns.  This is easily done by modifying the loop in the script gendata1.csv.   It is a good idea to copy this to a new script so it keeps the original as is</p>

<pre><code class="language-bash">cp gendata1.sh gendata2.sh
</code></pre>

<p>As gendata1.sh has write permissions, these will be preserved in the new copy of the file.   We can now edit  gendata2.sh</p>

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

<p>So all we are doing here is adding in, <strong>note the comma</strong></p>

<pre><code class="language-bash">, $((RANDOM % 20))
</code></pre>

<p>As the only difference between the lines</p>

<pre><code class="language-bash">echo $i, $((RANDOM % 20)), $((RANDOM % 20)) # echo to screen (stdout)
echo $i, $((RANDOM % 20)), $((RANDOM % 20)) &gt;&gt; log.csv # write to file
</code></pre>

<p>Is that the first line, writes to the screen, it may be better to test the script out, check it does what you want, then modify the line that writes to a file once you are happy.</p>

<p><strong>References</strong></p>

<p>1 <a href="https://www.gnuplot.info" rel="nofollow">gnuplot</a>
2 <a href="https://alvinalexander.com/technology/gnuplot-charts-graphs-examples/#4" rel="nofollow">gnuplot examples</a>
3. <a href="https://ctan.org/pkg/gnuplottex" rel="nofollow">GNU Plot and LaTeX</a>, included for reference</p>

<p><strong>Chat</strong></p>

<p>I am on the <a href="https://www.dcglug.org.uk/" rel="nofollow">Devon and Cornwall Linux user group</a> mailing list and also their <a href="https://matrix.to/#/%23dcglug:matrix.org" rel="nofollow">matrix channel</a> as zleap, it is better to ask there, that way others can answer too.</p>

<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:Files" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Files</span></a>,<a href="/paulsutton/tag:UsingDataFiles" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">UsingDataFiles</span></a>,<a href="/paulsutton/tag:Data" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Data</span></a>,<a href="/paulsutton/tag:gnuplot" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">gnuplot</span></a>,<a href="/paulsutton/tag:graphs" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">graphs</span></a>,<a href="/paulsutton/tag:BashScripting" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">BashScripting</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-17-using-data-files-3</guid>
      <pubDate>Sat, 19 Apr 2025 06:10:00 +0000</pubDate>
    </item>
    <item>
      <title>Bash scripting 16 – Using data files 2</title>
      <link>https://personaljournal.ca/paulsutton/bash-scripting-16-using-data-files-2</link>
      <description>&lt;![CDATA[Bash scripting 16 – Using data files 2&#xA;&#xA;So, carrying on from the previous article(s).  I am going to be using gnuplot and awk, and see what I can do with the data generated by my script.&#xA;&#xA;It would be useful to be able to remove content in the file we are using with awk, so new data is not added to existing data.&#xA;&#xA;We can do this by running:-&#xA;&#xA;echo &#34; &#34;   log.csv&#xA;This should ensure the file is empty&#xA;&#xA;we can then rerun&#xA;./gencsv1.sh &#xA;And check contents with&#xA;echo csv.log&#xA;&#xA;So according to the article,  we can list the data in the 2nd column&#xA;&#xA;awk -F, &#39;{ print $2}&#39; log.csv&#xA;&#xA; 2&#xA; 7&#xA; 14&#xA; 4&#xA; 5&#xA; 7&#xA; 17&#xA; 19&#xA; 0&#xA; 19&#xA;&#xA;and on a similar note, to list what is in the first column&#xA;awk -F, &#39;{ print $1}&#39; log.csv&#xA;and we can calculate the sum using&#xA;&#xA;awk -F, &#39;{ sum +=$2} END { print sum }&#39; log.csv&#xA;94&#xA;and the average&#xA;&#xA;awk -F, &#39;{ sum +=$2} END { print sum/NR }&#39; log.csv&#xA;8.54545&#xA;&#xA;Chat&#xA;&#xA;I am on the Devon and Cornwall Linux user group mailing list and also their matrix channel as zleap, it is better to ask there, that way others can answer too.&#xA;&#xA;Tags&#xA;&#xA;#Bash,#Bashscripting,#Files,#UsingDataFiles,#Data,#BashScripting&#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 16 – Using data files 2</p>

<p>So, carrying on from the previous article(s).  I am going to be using gnuplot and awk, and see what I can do with the data generated by my script.</p>

<p>It would be useful to be able to remove content in the file we are using with awk, so new data is not added to existing data.</p>

<p>We can do this by running:-</p>

<pre><code>echo &#34; &#34; &gt; log.csv
</code></pre>

<p>This should ensure the file is empty</p>

<p>we can then rerun</p>

<pre><code>./gencsv1.sh 
</code></pre>

<p>And check contents with</p>

<pre><code>echo csv.log
</code></pre>

<p>So according to the article,  we can list the data in the 2nd column</p>

<pre><code>awk -F, &#39;{ print $2}&#39; log.csv

 2
 7
 14
 4
 5
 7
 17
 19
 0
 19

</code></pre>

<p>and on a similar note, to list what is in the first column</p>

<pre><code>awk -F, &#39;{ print $1}&#39; log.csv
</code></pre>

<p>and we can calculate the sum using</p>

<pre><code>awk -F, &#39;{ sum +=$2} END { print sum }&#39; log.csv
94
</code></pre>

<p>and the average</p>

<pre><code>awk -F, &#39;{ sum +=$2} END { print sum/NR }&#39; log.csv
8.54545
</code></pre>

<p><strong>Chat</strong></p>

<p>I am on the <a href="https://www.dcglug.org.uk/" rel="nofollow">Devon and Cornwall Linux user group</a> mailing list and also their <a href="https://matrix.to/#/%23dcglug:matrix.org" rel="nofollow">matrix channel</a> as zleap, it is better to ask there, that way others can answer too.</p>

<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:Files" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Files</span></a>,<a href="/paulsutton/tag:UsingDataFiles" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">UsingDataFiles</span></a>,<a href="/paulsutton/tag:Data" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Data</span></a>,<a href="/paulsutton/tag:BashScripting" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">BashScripting</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-16-using-data-files-2</guid>
      <pubDate>Fri, 18 Apr 2025 06:00:00 +0000</pubDate>
    </item>
    <item>
      <title>Bash scripting 15 – Using data files 1</title>
      <link>https://personaljournal.ca/paulsutton/bash-scripting-15-using-data-files-1</link>
      <description>&lt;![CDATA[Bash scripting 15 – Using data files 1&#xA;&#xA;So, carrying on from the previous article.  I am going to be using gnuplot and awk, and see what I can do with the data generated by my script.&#xA;&#xA;So the first task, if of course to install gnu plot&#xA;&#xA;sudo apt install gnuplot&#xA;&#xA;It is also a good idea at this stage to determine version numbers of the tools we are using&#xA;&#xA;gnuplot -V&#xA;gnuplot 6.0 patchlevel 0&#xA;and &#xA;awk -V&#xA;GNU Awk 5.2.1, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)&#xA;Copyright (C) 1989, 1991-2022 Free Software Foundation.&#xA;&#xA;This program is free software; you can redistribute it and/or modify&#xA;it under the terms of the GNU General Public License as published by&#xA;the Free Software Foundation; either version 3 of the License, or&#xA;(at your option) any later version.&#xA;&#xA;This program is distributed in the hope that it will be useful,&#xA;but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&#xA;GNU General Public License for more details.&#xA;&#xA;You should have received a copy of the GNU General Public License&#xA;along with this program. If not, see http://www.gnu.org/licenses/.&#xA;&#xA;Tags&#xA;&#xA;#Bash,#Bashscripting,#Files,#UsingDataFiles,#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 15 – Using data files 1</p>

<p>So, carrying on from the previous article.  I am going to be using gnuplot and awk, and see what I can do with the data generated by my script.</p>

<p>So the first task, if of course to install gnu plot</p>

<pre><code class="language-bash">sudo apt install gnuplot
</code></pre>

<p>It is also a good idea at this stage to determine version numbers of the tools we are using</p>

<pre><code>gnuplot -V
gnuplot 6.0 patchlevel 0
</code></pre>

<p>and</p>

<pre><code>awk -V
GNU Awk 5.2.1, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)
Copyright (C) 1989, 1991-2022 Free Software Foundation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
</code></pre>

<p>Tags</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:Files" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Files</span></a>,<a href="/paulsutton/tag:UsingDataFiles" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">UsingDataFiles</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-15-using-data-files-1</guid>
      <pubDate>Thu, 17 Apr 2025 06:00:00 +0000</pubDate>
    </item>
    <item>
      <title>Bash scripting 14 - Generating data files</title>
      <link>https://personaljournal.ca/paulsutton/bash-scripting-14-generating-data-files</link>
      <description>&lt;![CDATA[Bash scripting 14 - Generating data files&#xA;&#xA;Issue 249, May 2025 of Linux Magazine, p52-55, had an article on using awk, and gnu plot to manipulate data.   In order to try and make use of this, and learn more, I am trying to figure out how to write a csv file. &#xA;&#xA;Write 10 lines to the first column should be in sequence e.g. 1-10 and the 2nd column should be random numbers.   This should be written to a file. &#xA;&#xA;So after some digging I managed to come up with this,  by modifying some existing solutions&#xA;&#xA;writecsv(){&#xA;    echo \&#34;$1\&#34;,\&#34;$2\&#34;   log.csv # write to file, use     to append&#xA;}&#xA;&#xA;sources of help&#xA;echo &#34;number&#34; &#34;data&#34; # for reference, not written to file &#xA;for ((i = 0 ; i &lt; 10 ; i++)); do&#xA;    echo $i, $RANDOM # echo to screen (stdout)&#xA;&#x9;echo $i, $RANDOM     log.csv # write to file&#xA;    #writecsv $(($i, $RANDOM % 10))&#xA;done&#xA;The screen output for me was&#xA;&#xA;number data&#xA;0, 17109&#xA;1, 2872&#xA;2, 22572&#xA;3, 7228&#xA;4, 27923&#xA;5, 6335&#xA;6, 20004&#xA;7, 32343&#xA;8, 10005&#xA;9, 21905&#xA;While the file output (log.csv) was similar but without the headings, which I just put in for my own reference,   the file does work as a csv as I can open in LibreOffice Calc. &#xA;&#xA;0, 17109&#xA;1, 2872&#xA;2, 22572&#xA;3, 7228&#xA;4, 27923&#xA;5, 6335&#xA;6, 20004&#xA;7, 32343&#xA;8, 10005&#xA;9, 21905&#xA;As the numbers are quite big,  a closer examination, promoted me to make the following modification&#xA;&#xA;echo $i, $((RANDOM % 20)) # echo to screen (stdout)&#xA;echo $i, $((RANDOM % 20))     log.csv # write to file&#xA;This fixes the 2nd column to produce a number between 1 and 20.&#xA;&#xA;number data&#xA;0, 17&#xA;1, 12&#xA;2, 12&#xA;3, 16&#xA;4, 2&#xA;5, 13&#xA;6, 10&#xA;7, 6&#xA;8, 16&#xA;9, 16&#xA;cat log.csv&#xA;0, 3&#xA;1, 17&#xA;2, 8&#xA;3, 16&#xA;4, 10&#xA;5, 18&#xA;6, 5&#xA;7, 14&#xA;8, 11&#xA;9, 11&#xA;&#xA;The script was called gencsv1.sh,  which as expected needed execute permissions &#xA;&#xA;chmod +x gencsv.sh&#xA;&#xA;References&#xA;&#xA;In order to help me I used the following, so giving credit to these sources as would be expected. &#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;&#xA;Tags&#xA;&#xA;#Bash,#Bashscripting,#Files,#Random,#Data,#CSV,&#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 14 – Generating data files</p>

<p>Issue 249, May 2025 of Linux Magazine, p52-55, had an article on using awk, and gnu plot to manipulate data.   In order to try and make use of this, and learn more, I am trying to figure out how to write a csv file.</p>

<p>Write 10 lines to the first column should be in sequence e.g. 1-10 and the 2nd column should be random numbers.   This should be written to a file.</p>

<p>So after some digging I managed to come up with this,  by modifying some existing solutions</p>

<pre><code class="language-bash">write_csv(){
    echo \&#34;$1\&#34;,\&#34;$2\&#34; &gt; log.csv # write to file, use &gt;&gt; to append
}

#sources of help
echo &#34;number&#34; &#34;data&#34; # for reference, not written to file 
for ((i = 0 ; i &lt; 10 ; i++)); do
    echo $i, $RANDOM # echo to screen (stdout)
	echo $i, $RANDOM &gt;&gt; log.csv # write to file
    #write_csv $(($i, $RANDOM % 10))
done
</code></pre>

<p>The screen output for me was</p>

<pre><code>number data
0, 17109
1, 2872
2, 22572
3, 7228
4, 27923
5, 6335
6, 20004
7, 32343
8, 10005
9, 21905
</code></pre>

<p>While the file output (log.csv) was similar but without the headings, which I just put in for my own reference,   the file does work as a csv as I can open in LibreOffice Calc.</p>

<pre><code>0, 17109
1, 2872
2, 22572
3, 7228
4, 27923
5, 6335
6, 20004
7, 32343
8, 10005
9, 21905
</code></pre>

<p>As the numbers are quite big,  a closer examination, promoted me to make the following modification</p>

<pre><code class="language-bash">echo $i, $((RANDOM % 20)) # echo to screen (stdout)
echo $i, $((RANDOM % 20)) &gt;&gt; log.csv # write to file
</code></pre>

<p>This fixes the 2nd column to produce a number between 1 and 20.</p>

<pre><code>number data
0, 17
1, 12
2, 12
3, 16
4, 2
5, 13
6, 10
7, 6
8, 16
9, 16
cat log.csv
0, 3
1, 17
2, 8
3, 16
4, 10
5, 18
6, 5
7, 14
8, 11
9, 11

</code></pre>

<p>The script was called gencsv1.sh,  which as expected needed execute permissions</p>

<pre><code>chmod +x gencsv.sh
</code></pre>

<p><strong>References</strong></p>

<p>In order to help me I used the following, so giving credit to these sources as would be expected.</p>
<ul><li><a href="https://stackoverflow.com/questions/40175868/how-to-create-csv-file-using-shell-script" rel="nofollow">https://stackoverflow.com/questions/40175868/how-to-create-csv-file-using-shell-script</a></li>
<li><a href="https://stackoverflow.com/questions/1194882/how-to-generate-random-number-in-bash" rel="nofollow">https://stackoverflow.com/questions/1194882/how-to-generate-random-number-in-bash</a></li>
<li><a href="https://linuxhandbook.com/bash-loops/" rel="nofollow">https://linuxhandbook.com/bash-loops/</a></li></ul>

<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:Files" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Files</span></a>,<a href="/paulsutton/tag:Random" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Random</span></a>,<a href="/paulsutton/tag:Data" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Data</span></a>,<a href="/paulsutton/tag:CSV" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">CSV</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-14-generating-data-files</guid>
      <pubDate>Wed, 16 Apr 2025 06:30:00 +0000</pubDate>
    </item>
  </channel>
</rss>