shell 自动切换日期

if [ -n "$1" ] && [ -n "$2" ];then
dt=$1
hours=$2
end_time=$dt' '$hours
start_time=`date --date="$end_time 1 hour ago" +"%Y-%m-%d %H"`
else 
start_time=`date --date="1 hour ago" +"%Y-%m-%d %H"`
end_time=$(date "+%Y-%m-%d %H")
dt=`date --date="1 hour ago" +"%Y-%m-%d"`
hours=`date -d "1 hour ago" +%H`
fi
posted @ 2021-01-13 15:57  JXiao1994  阅读(100)  评论(0编辑  收藏  举报