Need to increment the date from "currentdate + 90days" inside the for loop (i=1 to i=50)
What have you tried so far?
for i in {1..10}
do
date +"%d/%m/%y" --date="-$i days ago"
done
but getting the error
date: 0551-402 Invalid character in date/time specification.
Usage: date [-u] [+"Field Descriptors"]
Verify that you have GNU date
:
date --version
date (GNU coreutils) 5.97
If yes, then try:
for i in {1..10}
do
date --date="-${i} days ago" +"%d/%m/%y"
done
We are using AIX version not GNU. Provide the solution for AIX for date increment where --date is not supported.
If you have AIX you don't have a lot of options for date math. This snippet continues to come in handy:
for ((I=0; I<=50; I++))
do
DATE=$(perl -e 'use POSIX qw(strftime); print strftime "%Y/%m/%d\n", localtime(time()+($ARGV[0]*60*60*24));' -- -${I})
echo "got date $DATE"
done