👤
Home Man
Search
Today's Posts
Register


To run the script based on dates

Shell Programming and Scripting




Kindly Note - This is a Single User Post by Forum Member RudiC Regarding:
To run the script based on dates.
Please Follow The Primary Link Above to View the Full Discussion.

Old 12-07-2017
How about
Code:
FDT=$(date -d "$1 - 12 month" +"%Y-%m-%d")
for MP in $(seq 0 $2); do date -d "$FDT + $MP month" +"%Y-%m-%d"; done
2016-12-10
2017-01-10
2017-02-10
2017-03-10
2017-04-10
2017-05-10
2017-06-10
2017-07-10
2017-08-10
2017-09-10
2017-10-10
2017-11-10
2017-12-10

Be aware that this yields 13 iterations, for 12 months back and the current month.