Monday, 27 May 2013

Shell Script to count days in month

echo -n "Enter Month in numeric form:- "
read mnt
case $mnt in
1|3|5|6|8|10|12)
echo "In $mnt Month total 31 days are present"
;;
2)
if test `expr $mnt % 4` -eq 0
then
    echo "In $mnt Month total 29 days are present"
else
    echo "In $mnt Month total 28 days are present"
fi
;;
4|7|9|11)
    echo "In $mnt Month total 30 days are present"
;;
*)
    echo "Invalid Month"
;;
esac

No comments:

Post a Comment