[root@test shell2]# cat if_9.sh #!/bin/bash #判断某年是否为闰年 echo -n "请输入查询的年份:" read YEAR if [ $[$YEAR%4] -eq 0 -a $[$YEAR%100] -ne 0 ];then echo "$YEAR is 闰年" elif [ $[$YEAR%400] -eq 0 ];then echo "$YEAR is 闰年" else echo "$YEAR is 平年" fi 执行: [root@test shell2]# ./if_9.sh 请输入查询的年份:2020 2020 is 闰年 [root@test shell2]# ./if_9.sh 请输入查询的年份:2008 2008 is 闰年 [root@test shell2]# ./if_9.sh 请输入查询的年份:2019 2019 is 平年