Я обнаружил, что для того, что мне нужно, я могу просто оценить, будет ли это первая или вторая половина месяца.Мне удалось создать рабочий скрипт с помощью этой проверки:
current_month=$(date +%m)
current_day=$(date +%d)
if (( current_month == 1 )) && (( current_day < 16 ))
then
# January, first half
echo "January, first half"
elif (( current_month == 1 )) && (( current_day >= 16 ))
then
# January, second half
echo "January, second half"
elif (( current_month == 2 )) && (( current_day < 16 ))
then
# February, first half
echo "February, first half"
elif (( current_month == 2 )) && (( current_day >= 16 ))
then
# February, second half
echo "February, second half"
elif (( current_month == 3 )) && (( current_day < 16 ))
then
# March, first half
echo "March, first half"
elif (( current_month == 3 )) && (( current_day >= 16 ))
then
# March, second half
echo "March, second half"
elif (( current_month == 4 )) && (( current_day < 16 ))
then
# April, first half
echo "April, first half"
elif (( current_month == 4 )) && (( current_day >= 16 ))
then
# April, second half
echo "April, second half"
elif (( current_month == 5 )) && (( current_day < 16 ))
then
# May, first half
echo "May, first half"
elif (( current_month == 5 )) && (( current_day >= 16 ))
then
# May, second half
echo "May, second half"
elif (( current_month == 6 )) && (( current_day < 16 ))
then
# June, first half
echo "June, first half"
elif (( current_month == 6 )) && (( current_day >= 16 ))
then
# June, second half
echo "June, second half"
elif (( current_month == 7 )) && (( current_day < 16 ))
then
# July, first half
echo "July, first half"
elif (( current_month == 7 )) && (( current_day >= 16 ))
then
# July, second half
echo "July, second half"
elif (( current_month == 8 )) && (( current_day < 16 ))
then
# August, first half
echo "August, first half"
elif (( current_month == 8 )) && (( current_day >= 16 ))
then
# August, second half
echo "August, second half"
elif (( current_month == 9 )) && (( current_day < 16 ))
then
# September, first half
echo "September, first half"
elif (( current_month == 9 )) && (( current_day >= 16 ))
then
# September, second half
echo "September, second half"
elif (( current_month == 10 )) && (( current_day < 16 ))
then
# October, first half
echo "October, first half"
elif (( current_month == 10 )) && (( current_day >= 16 ))
then
# October, second half
echo "October, second half"
elif (( current_month == 11 )) && (( current_day < 16 ))
then
# November, first half
echo "November, first half"
elif (( current_month == 11 )) && (( current_day >= 16 ))
then
# November, second half
echo "November, second half"
elif (( current_month == 12 )) && (( current_day < 16 ))
then
# December, first half
echo "December, first half"
elif (( current_month == 12 )) && (( current_day >= 16 ))
then
# December, second half
echo "December, second half"
else
# Error
echo "Error: Invalid date"
fi