sample shell script to loop between the date ±1 specified by argument
This is sample shell script to loop between the date ±1 specified by argument.
#!/bin/sh START=$1 END=$2 START_1DAY_BEFORE=`date '+%Y%m%d' -d "1 days ago ${START}"` END_1DAY_AFTER=`date '+%Y%m%d' -d "-1 days ago ${END}"` echo $START_1DAY_BEFORE for j in {0..10000}; do TARGET_YYYYMMDD=`date '+%Y%m%d' -d "-$j days ago ${START_1DAY_BEFORE}"` echo ${TARGET_YYYYMMDD} if [ ${TARGET_YYYYMMDD} -gt ${END_1DAY_AFTER} ]; then break fi done