Created
June 26, 2019 05:16
-
-
Save tkarna/3750dd1295ff6d28a98dc78470c4cfa7 to your computer and use it in GitHub Desktop.
Loop through days of 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 | |
# loop through days of month given the first day | |
startdate="2019-06-01" | |
enddate=$(date -d "$startdate + 1 month" +"%Y-%m-%d") | |
ndays=$(( ($(date -d "$enddate" +%s) - $(date -d "$startdate" +%s) )/(60*60*24) )) | |
for i in $(seq 0 $(($ndays - 1)) ); do | |
date=$(date -d "$startdate + $i days" +"%Y-%m-%d") | |
echo $date | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment