Created
February 26, 2020 20:37
-
-
Save alexras/9854d4909be6b858c88d66bf3d69e4cb to your computer and use it in GitHub Desktop.
Loop through dates by month in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
start_date=2019-10-01 | |
end_date=2019-10-31 | |
while [ "$start_date" != 2017-10-01 ] | |
do | |
echo $start_date $end_date | |
start_date=$(gdate -I -d "$start_date - 1 month") | |
end_date=$(gdate -I -d "$start_date + 1 month - 1 day") | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment