#!/bin/bash# FileName: alldateduringtwodays1.sh# Description: Print all the date during the two days you inpute.#Simple Usage:sh repo_asset_3days.sh 2017-04-01 2017-06-14 /user/etl/fa45/dwd/repo_asset.sql &echo"input param length:" $# if[[ $# -ne 3 ]]; thenecho"#Simple Usage:sh repo_asset_3days.sh 2017-04-01 2017-06-14 /user/etl/fa45/dwd/repo_asset.sql &"exit 1
fi
START_DAY=$(date -d "$1"+%s)
END_DAY=$(date -d "$2"+%s)# The spliter bettwen year, month and day.
SPLITER=-# Declare an array to store all the date during the two days you inpute.
declare -a DATE_ARRAY
function genAlldate
{echo"genAlldate input param length:" $#if[[ $# -ne 3 ]]; thenecho"#params eg. 2017-04-01 2017-06-14 -"exit 1
fi
START_DAY_TMP=${1}
END_DAY_TMP=${2}
SPLITER_TMP=${3}
I_DATE_ARRAY_INDX=0
# while [[ "${START_DAY}" -le "${END_DAY}" ]]; dowhile(("${START_DAY_TMP}" <= "${END_DAY_TMP}"));do
cur_day=$(date -d @${START_DAY_TMP}+"%Y${SPLITER_TMP}%m${SPLITER_TMP}%d")
DATE_ARRAY[${I_DATE_ARRAY_INDX}]=${cur_day}# We should use START_DAY_TMP other ${START_DAY_TMP} here.
START_DAY_TMP=$((${START_DAY_TMP}+86400))((I_DATE_ARRAY_INDX++))#sleep 1
done
}# Call the funciotn to generate date during the two days you inpute.
genAlldate "${START_DAY}""${END_DAY}""${SPLITER}"# [Method 1] Traverse the array.echo-e "output the date array."
WORK_DIR=`pwd`
for SINGLE_DAY in ${DATE_ARRAY[@]};doecho ${SINGLE_DAY}
sh ~/etl_app/fa45/bin/dwd/incre/repo_asset.sh $3 ${SINGLE_DAY}
done
exit 0