#!/bin/bash

#用例:isendofmonth.sh 20180207

#判断输入参数是否合法
if [ $# != 1 ] 
then 
echo "" 
echo "parameter error !" 
echo "usage:sh $0 <DATE>" 
echo "" 
exit 1 
fi

#获取输入日期
curDate=$1
curDay=`echo $curDate | cut -c 7-8`
curMonth=`echo $curDate | cut -c 5-6`
curYear=`echo $curDate | cut -c 1-4`

#获取月末日期
curCal=`cal $curMonth $curYear` 
endDay=`echo $curCal | awk '{print $NF}'`
#echo $endDay

#判断是否为月末
if [ "$curDay" -eq "$endDay" ] 
then 
    echo "输入日期是月末!"
else
    echo "输入日期不是月末!"
fi
posted on 2018-02-07 11:23  明星程序员  阅读(2234)  评论(0)    收藏  举报