|
How to perform Date Intervals?
I have a 300 line script which generates key performance indicators for one of our systems. Since I just started learning sh/ksh half a month ago there's still a lot I haven't had experience with yet.
Currently, the script generates the report for a specific day. (It takes the date specified by the user such as 20050621 (yyyymmdd) and then does something like "ls -al | grep <date format>" to retrieve csv files for that particular day.
I need some guidance/advice on how I could take this script and loop it for date intervals: The user can input two dates, such as "I want to generate reports for everyday in between 20040415 to 20050620 and I don't wish to include weekends".
I was thinking maybe something like.. create a bunch of start and end variables before the loop and then running a bunch of nested while loops or some other kind of loop that goes through first the year, then the month, then the days. Does this sound okay or does anyone suggest an easier approach?
Is there another command that is similar to what the date/time format for the crontab command does? Because in crontab you can choose everything down to the second, with exceptions.
I just don't want to reinvent the wheel if I don't need to because I'd have to code how to calculate the leap year, and then the days of each month, etc
|