Shell Script to Check Leap Year

This shell script is used to find given year is Leap year or not by checking the condition: y=$(( $y % 4 )). If the remainder stored in the variable y is 0 then the year is Leap year else it is not a Leap year.

echo "Enter Year:"
read y

year=$y

y=$(( $y % 4 ))
if [ $y -eq 0 ]
then
	echo "$year is Leap Year!"
else
	echo "$year is not a Leap Year!"
fi

Output:
leap

Leave a Reply