shell中实施年月日的判断
#!/bin/sh
#
if [ $MON = 01 ]
then
YEAR=`expr $YEAR - 1`
if [ $YEAR -lt 10 ]
then
YEAR="0$YEAR"
fi
fi
if [ $MON -ge 2 ]
then
MON=`expr $MON - 1`
if [ $MON -lt 10 ]
then
MON="0$MON"
fi
else
MON=12
fi
case $MON in
01|03|05|07|08|10|12)
DATE=31;;
04|06|09|11)
DATE=30;;
02)
DATE=28;;
esac
TRIGGER=`expr $YEAR % 4`
if [ $TRIGGER = 0 -a $DATE = 28 ]
then
DATE=29
fi
阅读(1409) | 评论(0) | 转发(0) |