加载中…
个人资料
凡不庸
凡不庸
  • 博客等级:
  • 博客积分:0
  • 博客访问:1,759
  • 关注人气:12
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

shell脚本中判断日期是否是月末的程序

(2011-02-23 09:20:34)
标签:

杂谈

. /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 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有