shell脚本打印时间命令

# +%Y%m%d 为指定显示格式

#本月 202304

month=`date +%Y%m`

#今日日期 20230406

curr_date=`date +%Y%m%d`

#本月第一天 20230401

curr_month_begin=`date -d "${curr_date}" "+%Y%m01"`

curr_month_begin=`date +%Y%m01`

#本月最后一天

curr_month_end=`date -d "${next_month_begin} -1 day" "+%Y%m%d"`

curr_month_end=`date -d "$(date +%Y%m01) +1 month -1day" +%Y%m%d`

#下月第一天

next_month_begin=`date -d "${curr_month_begin} +1 month" "+%Y%m01"`

next_month_begin=`date -d "$(date +%Y%m01) +1 month " +%Y%m%d`

curr_month_end=`date -d "${next_month_begin} -1 day" "+%Y%m%d"`

#明天

1_day_ago=`date -d "1 day ago" +"%Y%m%d"`

猜你喜欢

转载自blog.csdn.net/weixin_59679023/article/details/129988934