Re: script to loop through dates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






Sent from ProtonMail, encrypted email based in Switzerland.

Sent with Proton Mail secure email.

On Friday, June 27th, 2025 at 8:52 AM, Todd Zullinger <tmz@xxxxxxxxx> wrote:

> olivares33561 via users wrote:
> 
> > It does not print start day four times. Almost there.
> 
> 
> I'm curious why you'd want the start date printed 4 times?

I have high blood pressure (hypertension).  I take two readings in the morning, and two at afternoon or night.  
> 
> To do that, you'd want to move your for loop outside of the
> while loop, I think. Though there is, as usual, more than
> one way to do it. ;)
> 
> I think this is one way, as a hopefully helpful example
> which includes the minor changes I mentioned in my previous
> message.
> 
> #!/bin/bash
> 
> start=$1
> end=$2
> 
> start=$(date -d ${start//./-} +%Y%m%d)
> end=$(date -d ${end//./-} +%Y%m%d)
> 
> for i in {1..3}; do
> date -d"$start" +%Y.%m.%d
> done
> 
> while (( start < end ))
> do
> date -d"$start" +%Y.%m.%d
> start=$(date -d"$start + 1 day" +%Y%m%d)
> done
> 
> This could be improved (arguably) by keeping the date
> strings in a form which the date command understands and
> only formatting them with "." separators when printing for
> output.
> 
> --
> Todd
> --

I use a script for gnuplot to plot the systolic|diastolic|heart rate|blood sugar 

set grid

#set size ratio -1
set title 'Blood Pressure and Heart Rate'
set xlabel 'Time (military)'
set ylabel 'Blood Pressure (mmHg)'
set y2label 'Heart Rate (bpm)'
set datafile separator whitespace

set timefmt "%Y.%m.%d:%H%M"
set xdata time
set format x "%Y.%m.%d:%H%M"

set xtics rotate

plot 'data.txt' using 1:2 with linespoints title 'Systolic Blood Pressure' lt 1,\
     'data.txt' using 1:3 with linespoints title 'Diastolic Blood Pressure' lt 2,\
     'data.txt' using 1:4 with linespoints title 'Heart Rate' lt 3, \
     120 ls -1, 80 ls -1, 60 ls 0

And the data for example 

# %Y.%m.%d:%H%M systolic diastolic heart_rate blood_sugar fasting/random 
2025.06.01:0856 118 82 80 104 #FBS
2025.06.01:0902 119 84 80
2025.06.01:1928 120 76 115
2025.06.01:1934 118 73 110
2025.06.02:0705 120 93 81 113 #FBS
2025.06.02:0710 136 90 76
2025.06.02:1930 120 76 111
2025.06.02:1936 103 73 110
2025.06.03:0820 125 90 79 123 #FBS
2025.06.03:0826 123 85 83
2025.06.03:1930 112 74 93
2025.06.03:1936 111 80 92
2025.06.04:0830 111 73 85 126 #FBS
2025.06.04:0835 115 79 88
2025.06.04:1906 102 68 108
2025.06.04:1912 113 71 106
2025.06.05:0715 116 77 84 138 #FBS
2025.06.05:0722 122 79 83
2025.06.05:1854 113 76 99
2025.06.05:1900 115 75 102
2025.06.06:0910 113 81 82 140 #FBS
2025.06.06:0916 118 78 78
2025.06.06:1930 116 74 102
2025.06.06:1936 106 65 98
2025.06.07:0718 124 89 80 92 #FBS
2025.06.07:0725 122 76 79
2025.06.07:1820 121 76 105
2025.06.07:1834 112 72 107
2025.06.08:0920 125 78 88 127 #FBS
2025.06.08:0925 124 79 90
2025.06.08:2012 117 75 92
2025.06.08.2018 125 77 95
2025.06.09:0708 125 83 82 155 #FBS
2025.06.09:0716 127 81 83
2025.06.09:1855 108 67 102
2025.06.09:1902 102 62 101
2025.06.10:0715 135 93 81 127 #FBS
2025.06.10:0720 127 93 79
2025.06.10:1952 107 69 102
2025.06.10:2000 101 65 100
2025.06.11:0812 126 77 80 113 #FBS
2025.06.11:0820 125 85 82
2025.06.11:1948 114 78 100
2025.06.11:1956 117 77 97
2025.06.12:0725 136 93 96 132 #FBS
2025.06.12:0730 135 85 80
2025.06.12:1844 124 90 100
2025.06.12:1850 116 87 92
2025.06.13:1041 104 74 108 106 #FBS
2025.06.13:1046 111 72 102
2025.06.13:1822 128 88 94
2025.06.13:1830 107 74 94 124 #FBS
2025.06.14:0716 130 87 92
2025.06.14:0722 132 90 96
2025.06.14:1930 121 86 95
2025.06.14:1936 124 83 96
2025.06.15:0915 123 81 77
2025.06.15:0922 132 80 97
2025.06.15:1952 125 83 82
2025.06.15:1958 122 79 76

I wanted to save time, and thanks to all I can now just run the script to get the dates, I will add the ":", the %H%M , and the readings.  I will be set.
Just copy + paste.  

For instance I can use this website 

https://hostcat.fhsu.edu/cdclark/static/apps/gnuplot/

To view in realtime and show the doctor the readings.




Best Regards,



Antonio

-- 
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux