pgm-2:/home/ims/cdr/siphistory/send # file_name=`date +%Y%m%d`
pgm-2:/home/ims/cdr/siphistory/send # date -d "+1 day ${file_name}" +%Y%m%d
20110825
pgm-2:/home/ims/cdr/siphistory/send # date -d "-1 day ${file_name}" +%Y%m%d
20110823
pgm-2:/home/ims/cdr/siphistory/send # date -d "+2 day ${file_name}" +%Y%m%d
20110826
pgm-2:/home/ims/cdr/siphistory/send # date -d "+222day ${file_name}" +%Y%m%d
20120402
pgm-2:/home/ims/cdr/siphistory/send # date -d "-156 day ${file_name}" +%Y%m%d
20110321
pgm-2:/home/ims/cdr/siphistory/send #
就不用自己想着定制shell函数,把测试结果页写下来,呵呵不错
linux下
前一天的日期
date -d"1 day ago" +"%y%m%d"
前一个月的日期
date -d"1 month ago" +"%y%m%d"
类似的还有
date -d"-1 day ago 1 month ago" +"%y%m%d"
date -d"1 day ago -1 year ago 1 month ago" +"%y%m%d"
阅读(3539) | 评论(0) | 转发(0) |