How to loop through dates using Bash?

后端 未结 8 732
一整个雨季
一整个雨季 2020-12-02 06:22

I have such bash script:

array=( \'2015-01-01\', \'2015-01-02\' )

for i in \"${array[@]}\"
do
    python /home/user/executeJobs.py {i} &> /home/user/         


        
8条回答
  •  独厮守ぢ
    2020-12-02 06:48

    If one wants to loop from input date to any range below can be used, also it will print output in format of yyyyMMdd...

    #!/bin/bash
    in=2018-01-15
    while [ "$in" != 2018-01-25 ]; do
      in=$(date -I -d "$in + 1 day")
      x=$(date -d "$in" +%Y%m%d)
      echo $x
    done
    

提交回复
热议问题