question:
需要知道某个日期前n天的日期
eg:
需要知道20110417前10天的日期是什么
$now=20110417 #转为秒 day_second=`date -d"$NOW" +%s`; #计算20天的秒数 seconds=`expr 86400 /* 10` #计算20天前时间的秒 history_second=`expr $day_second - $seconds` #20天前应该显示的天 history_day=`date -d"1970-01-01 UTC $history_second seconds" +%Y%m%d` #搞定,输出20110407 echo $ history_day
834

被折叠的 条评论
为什么被折叠?



