Re: script to loop through dates

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

 




> On 27 Jun 2025, at 12:32, olivares33561 via users <users@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> Dear Fedora users,
> 
> I am struggling to create a script that generates a series of dates with special "+%Y.%m.%d" like the following

Do you know python? It would be a lot easier to solve using a small amount of python scripting.

Barry

> 
> 2025.06.01
> 2025.06.01
> 2025.06.01
> 2025.06.01
> 2025.06.02
> ..
> ..
> ..
> 2025.06.03
> ..
> ..
> ..
> .
> Through
> 2025.06.30
> 
> Print four dates of June 1, then June 2, all the way through to June 30
> 
> I found several examples but can't succeed to get what I want
> ------
> 
> #!/bin/bash
> start=$1
> end=$2
> 
> start=$(date -d $start +%Y%m%d)
> end=$(date -d $end +%Y%m%d)
> 
> while [[ $start -le $end ]]
> do
>    echo $start
>    start=$(date -d"$start + 1 day" +"%Y%m%d")
> done
> ------
> 
> bash daterange.sh 2025-07-01 2025-07-16
> 20250701
> 20250702
> 20250703
> 20250704
> 20250705
> 20250706
> 20250707
> 20250708
> 20250709
> 20250710
> 20250711
> 20250712
> 20250713
> 20250714
> 20250715
> 20250716
> 
> I found the script here:
> 
> 
> https://techieroop.com/loop-through-a-date-range-in-shell-script/
> 
> 
> Fix it to print for example above
> 
> 2025.07.01
> 2025.07.01
> 2025.07.01
> 2025.07.01
> 2025.07.02
> ..
> ..
> ..
> .
> .
> .
> 2025.07.16
> 
> I have changed date format to %Y.%m.%d but I get errors
> 
> .../Download/mptmp $ bash daterange.sh 2025-07-01 2025-07-16
> daterange.sh: line 8: [[: 2025.07.01: syntax error: invalid arithmetic operator (error token is ".07.01")
> .../Download/mptmp $ bash daterange.sh 2025.07.01 2025.07.16
> date: invalid date ‘2025.07.01’
> date: invalid date ‘2025.07.16’
> 
> daterange.sh: line 8: [[: 2025.06.27: syntax error: invalid arithmetic operator (error token is ".06.27")
> 
> 
> How can it be fixed to do what I want?
> 
> Best Regards,
> 
> 
> Antonio
> 
> 
> Sent from ProtonMail, encrypted email based in Switzerland.
> 
> Sent with Proton Mail secure email.
> <publickey - olivares33561@xxxxxxxxxxxxxx - 0x865D4DD3.asc>
> --
> _______________________________________________
> 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

-- 
_______________________________________________
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