手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >获取两个日期间隔时间的shell脚本代码
获取两个日期间隔时间的shell脚本代码
摘要:复制代码代码如下:#!/bin/sh#获取所在季度的第一天,到昨天的日期间隔#link:www.jb51.net#date:2013/2/2...

复制代码 代码如下:

#!/bin/sh

# 获取所在季度的第一天,到昨天的日期间隔

# link:www.jb51.net

# 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

【获取两个日期间隔时间的shell脚本代码】相关文章:

查找目录下同名但不同后缀名文件的shell脚本代码

VPS自动备份数据库到FTP的脚本代码

在指定目录查找指定后缀文件的shell脚本代码

把文件复制N份的2个Shell脚本代码

统计 cpu 内存 使用率的shell脚本代码

后台实时分流文件的shell脚本

kill特定进程的shell脚本代码

一个简单的转换输出的shell脚本代码

两个备份数据库的shell脚本

判断文件是否存在的shell脚本代码

精品推荐
分类导航