In the Linux environment to get a few days before the time just use
date-d "x days Ago" +%y%m%d
X is replaced by a number, if it takes a few days before the direct write positive, if a few days after the date directly write negative numbers can be;
date-d "x weeks Ago" +%y%m%d
X is replaced by a number, if it takes a few weeks before the direct write positive, if a few weeks after the date directly write negative numbers;
date-d "x years ago" +%y%m%d
X is replaced by a number, if it takes a few years before the direct write positive, if a few years after the date directly write negative numbers can be;
Look at the following example:
[Email protected] ~]# date +%y%m%d
20100107
The above is today's date 20100107
[[email protected] ~]# date-d "2 days ago" +%y%m%d
20100105
It's dated two days ago.
[[email protected] ~]# date-d "4 days Ago" +%y%m%d
20100103
above is the date four days ago
[[email protected] ~]# date-d"-1 days Ago "+%y%m%d
20100108
above is a day after the date
[[email protected] ~]# date-d"-2 days Ago "+%y%m%d
20100109
above is two days after the date
[Email protected] ~]# date-d "1 week Ago" +%y%m%d
20091231
It's a week ago.
[[email protected] ~]# date-d "1 year ago" +%y%m%d
20090107
It was dated a year ago.
How to get a date from a few days ago or a few days after Linux