Loop through a date range in Shell Script
Loop through a date range in Shell Script
Here is a simple shell script which accept two date value as argument and perform desired action for date value in loop.
daterange.sh
#!/usr/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
Uses:
daterange.sh 2019-01-01 2019-01-31
Please refer my previous article to validate date arguments
https://techieroop.com/pass-dates-as-mandatory-arguments-in-bash-script/
(Visited 6,431 times, 288 visits today)