您的位置:首页 > 运维架构 > Shell

shell 取得上个月的开始结束日期

2015-11-12 13:15 543 查看
#!/bin/bash
if [ $# -eq 1 ]; then
day=$1
else
day=`date +%Y%m%d`
fi
tmp_day_dis=$(date +%e -d "${day}")
day_dis=$(expr $tmp_day_dis - 1)
end_last_month=`date +%Y%m%d -d "-${tmp_day_dis} day ${day}"`
last_month=`date +%Y%m%d -d "-1 month ${day}"`
start_last_month=`date +%Y%m%d -d "-${day_dis} day ${last_month}"`
echo $end_last_month
echo $start_last_month
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: