shell 实现闰年的判断

#!/bin/sh
echo "please input the year"
read year

let "n1=$year % 4"
let "n2=$year % 100"
let "n3=$year % 400"

if [ "$n1" -ne 0 ]
then
let "flag=0"
elif [ "$n2" -ne 0 ]
then
let "flag=1"
elif [ "$n3" -ne 0 ]
then
let "flag=0"
else
let "flag=1"
fi

if [ $flag -eq 1 ]
then
echo "the year input is true"
else
echo "what you input is false"
fi

原文地址:https://www.cnblogs.com/luo-mao/p/5937753.html