#!/bin/bash
n=$1
#If the entered variable is empty:
if [ -z $n ];
then
    echo "No month entered. Displaying even months."
    for (( x=2 ; x<=12 ; x=x+2 ));
    do
        cal $x 2022
    done
    exit 0
fi
#The following regex matches any variable composed entirely of digits from beginning (^) to end (+$)
re='^[0-9]+$'
#If the entered variable does not match this pattern.
#The =~ allows regex comparison in Bash.s
if [[ ! $n =~ $re ]];
then
    echo "$n is not a number."
exit 1
#Check to see if n is less than one or greater than 12.
elif [[ $n -lt 1 || $n -gt 12 ]];
then
    echo "$n is not a month."
exit 1
fi
echo "Month: $n"
let next=12-$n
echo "Remaining months: $next"
#Now use the -A/-n flag with cal to print remaining months in 2022.
cal -n $next $n 2022