闰年脚本
#!/bin/bash
echo "please input a year; "
read year
let " n1 = $year % 4 "
let "n2 = $year % 100"
let "n3 = $year % 400"
if [ ! "n1" -eq 0 ]
then
leap = 0
elif [ ! "n2" -eq 0 ]
then
leap = 1
elif [ ! "n3" -eq 0 ]
then
leap = 0
else
leap = 1
fi
if [ "leap" -eq 1 ]
then
echo "$year is a leap year!"
else
echo "$year is not a year!"
fi
时间: 2024-10-24 10:26:47