Created
March 14, 2016 14:45
-
-
Save kristapsk/43693f581dbe40af913e to your computer and use it in GitHub Desktop.
Bash date loop
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 | |
date_start="2015-01-01" | |
date_end="2015-12-31" | |
date_start_unixtime="`date --date="$date_start" +"%s"`" | |
date_end_unixtime="`date --date="$date_end" +"%s"`" | |
date_current=$date_start | |
date_current_unixtime=$date_start_unixtime | |
echo $date_current_unixtime - $date_end_unixtime | |
while [ "$date_current_unixtime" -le "$date_end_unixtime" ]; do | |
date +"%d.%m.%Y" -d "$date_current" | |
date_current="`date +"%Y-%m-%d" -d "$date_current + 1 DAY"`" | |
date_current_unixtime="`date --date="$date_current" +"%s"`" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment