Get the date of the days before today on AIX

前端之家收集整理的这篇文章主要介绍了Get the date of the days before today on AIX前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

The date command in AIX doesn't support "-d" switch. So it is not easy to get the date of the days before (or after) today.

After research,I think it is best to use perl to compute the date we want.

Here it is:

#!/usr/bin/env sh
DAYS=-5
DATE=`DAYS=$DAYS perl -MPOSIX -le 'print strftime("%Y%m%d",localtime(time() + $ENV{'DAYS'} *24 *60 *60))'`

#echo $DATE

猜你在找的Perl相关文章