Search Here

Shell Script to modify cal command of UNIX to include the following: i) Print the current month and current year when called without parameter ii) print the calendar of month of the current year if only one argument between 1 and 12


if (( $#==0 ))
then
    m=`date +%m`
elif(( $#==1 ))
then
    if(( $1>=1 && $1<=12 ))
    then
        m=$1
    else
        echo "Invalid month given"
        exit
    fi
else
    echo "Improper number of arguments"
    exit
fi

y=`date +%Y`

cal $m $y

No comments:

Post a Comment