. /home/racky/.profile
DT1=$1 #接收输入的时间参数,格式YYYYMMDD
year=`echo $DT|cut -c1-4`
month=`echo $DT|cut -c5-6`
day=`echo $DT|cut -c7-8`
#取当前月末天,取得$year年$month月的月末天
monthend=`cal $month $year | xargs | awk '{print $NF}'`
echo $monthend
today=$day
#today=`date +%d`
echo $today
if [ $today -eq $monthend ]
then
echo "$DT the month end"
echo "月末"
else
echo "$DT not the month end"
echo "不是月末"
fi
chmod u+x monthend.sh,修改脚本的执行权限
./monthend.sh 20091213执行即可
DT1=$1 #接收输入的时间参数,格式YYYYMMDD
year=`echo $DT|cut -c1-4`
month=`echo $DT|cut -c5-6`
day=`echo $DT|cut -c7-8`
#取当前月末天,取得$year年$month月的月末天
monthend=`cal $month $year | xargs | awk '{print $NF}'`
echo $monthend
today=$day
#today=`date +%d`
echo $today
if [ $today -eq $monthend ]
then
echo "$DT the month end"
echo "月末"
else
echo "$DT not the month end"
echo "不是月末"
fi
chmod u+x monthend.sh,修改脚本的执行权限
./monthend.sh 20091213执行即可