RSS

Print Date Range Shell Script

Update: This had a bug in it when printing ranges in the same month. This problem is now corrected and the file can be redownloaded at the same location.

If you have ever dealt with this problem before, you know it is a pain in the head. You have two dates and you need to print all the dates in between the two dates inclusively, but that darn Gregorian Calendar system has all uneven months. Furthermore after you get through twelve months you have to start a whole new year. The logic for this was just as painful to write as it looks in shell, but this is a very useful script and one I do not want to write again. You can download it here.

This is how it works:

Example: ./validateDate.sh -d “1337-01-04-09 to 1337-02-12-09″

Output:

1337-01-04
1337-01-05
1337-01-06
1337-01-07
1337-01-08
1337-01-09
1337-01-10
1337-01-11
1337-01-12
1337-01-13
1337-01-14
1337-01-15
1337-01-16
1337-01-17
1337-01-18
1337-01-19
1337-01-20
1337-01-21
1337-01-22
1337-01-23
1337-01-24
1337-01-25
1337-01-26
1337-01-27
1337-01-28
1337-01-29
1337-01-30
1337-01-31
1337-02-01
1337-02-02
1337-02-03
1337-02-04
1337-02-05
1337-02-06
1337-02-07
1337-02-08
1337-02-09
1337-02-10
1337-02-11
1337-02-12

Leave a Reply

*