Thanks for that info catkin as I needed to some assistance in trying to formulate an approach to scripting this issue.
Code:
#!/bin/bash
# Leap year check
currentmonth=$(date +%B)
month=$(date +%m)
year=$(date +%Y)
echo "The current month is $currentmonth"
if [[ $month = 01 ]]; then
echo "$month has 31 days"
elif [[ $month = 02 ]]; then
if (( $year % 400 != 0 )); then
echo "$month has 28 days"
else
echo "$month has 29 days"
fi
elif [[ $month = 03 ]]; then
echo "$month has 31 days"
elif [[ $month = 04 ]]; then
echo "$month has 30 days"
elif [[ $month = 05 ]]; then
echo "$month has 31 days"
elif [[ $month = 06 ]]; then
echo "$month has 30 days"
elif [[ $month = 07 ]]; then
echo "$month has 31 days"
elif [[ $month = 08 ]]; then
echo "$month has 31 days"
elif [[ $month = 09 ]]; then
echo "$month has 30 days"
elif [[ $month = 10 ]]; then
echo "$month has 31 days"
elif [[ $month = 11 ]]; then
echo "$month has 30 days"
elif [[ $month = 12 ]]; then
echo "$month has 31 days"
else
echo "Programming error: \$month not in expected 01-12 range: $month" >&2
fi
Not correct yet as:
The current month is April
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
leaptest.sh: 40: [[: not found
Programming error: $month not in expected 01-12 range: 04
It has a problem with the final "fi" in the script.