#! /bin/bashecho -n Input year to judge if it is a leap year:read yearlet "y1=$year % 4"let "y2=$year % 100"let "y3=$year % 400"if [ ! "$y1" -eq 0 ]thenleap=0elif [ ! "$y2" -eq 0 ]thenleap=1elif [ "$y3" -eq 0 ]thenleap=1elseleap=0fiif [ "$leap" -eq 1 ]thenecho "$year is a leap year"elseecho "$year is not a leap year"fi
[root@lenny Desktop]# ./ifrunnian.sh Input year to judge if it is a leap year:20032003 is not a leap year[root@lenny Desktop]# ./ifrunnian.sh Input year to judge if it is a leap year:20052005 is not a leap year[root@lenny Desktop]# ./ifrunnian.sh Input year to judge if it is a leap year:20082008 is a leap year