Unix/Linux Go Back    



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 Unix and Linux 5 Days Ago   -   Original Discussion by rohit_shinez
RudiC's Unix or Linux Image
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 12 December 2017, 12:54 PM EST
Location: Aachen, Germany
Posts: 11,789
Thanks: 339
Thanked 3,659 Times in 3,357 Posts
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.