#!/bin/sh# 获取所在季度的第一天,到昨天的日期间隔# link:www.lsjlt.com# date:2013/2/28 day=`date -d "1 days aGo " "+%Y%m%d
#!/bin/sh
# 获取所在季度的第一天,到昨天的日期间隔
# link:www.lsjlt.com
# date:2013/2/28
day=`date -d "1 days aGo " "+%Y%m%d"`;
year=`expr substr ${day} 1 4`;
month=`expr substr ${day} 5 2`;
s_date=$year"0101"
if [ "$month" == "01" ] || [ "$month" == "02" ] || [ "$month" == "03" ];then
s_date=$year"0101"
elif [ "$month" == "04" ] || [ "$month" == "05" ] || [ "$month" == "06" ];then
s_date=$year"0401"
elif [ "$month" == "07" ] || [ "$month" == "08" ] || [ "$month" == "09" ];then
s_date=$year"0701"
elif [ "$month" == "10" ] || [ "$month" == "11" ] || [ "$month" == "12" ];then
s_date=$year"1001"
fi
e_date=$day
sys_s_data=`date -d "$s_date" +%s`
sys_e_data=`date -d "$e_date" +%s`
interval=`expr $sys_e_data - $sys_s_data`
daycount=`expr $interval / 3600 / 24 + 1`
echo $daycount
--结束END--
本文标题: 获取两个日期间隔时间的shell脚本代码
本文链接: https://lsjlt.com/news/18076.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0