Check for leap year in Shell Script
 


This shell script accepts a year and checks if the entered year is leap year or not.
year=0

echo -n "Enter the year, I will tell you whether its Leap year or Not? "
read year

ans=$(($year % 4))  # or try ans=`expr $year % 2`

if [ $ans -eq 0 ]; then
   echo "$year is Leap Year"
else
   echo "$year is NOT Leap Year"
fi

 
 
 
 
 
COPYRIGHT © 2017 java-samples.com. ALL RIGHTS RESERVED.