I have a bash script which checks if the input date($1) falls in a range/ranges of dates. User inputs a date and (a or b, which is $2).
#!/usr/bin/env bash
today=$(date +"%Y%M%d")
declare -A dict=$2_range
a_range=( ["20140602"]="20151222" ["20170201"]="$today" )
b_range=( ["20140602"]="20150130" )
for key in ${!dict[@]}; do
if [[ $1 -le ${dict[$key]} ]] && [[ $1 -ge $key ]]; then
echo $1 falls in the range of $2
fi
done
I do not know how to copy the associative array to the dict variable. Sample usage
$ ./script.sh 20170707 a
20170707 falls in the range of a