Created
July 2, 2021 00:23
-
-
Save komasaru/31178555f140e1b459dae0aecf03984d to your computer and use it in GitHub Desktop.
Bash script to loop by date.
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_S="20201226" | |
DATE_E="20210105" | |
# Example-1 | |
for (( dt=$DATE_S ; $dt < $DATE_E ; dt=`date -d "$dt 1 day" '+%Y%m%d'` )) ; do | |
echo $dt | |
done | |
echo "---" | |
# Example-2 | |
dt=$DATE_S | |
while [[ $dt < $DATE_E ]] ; do | |
echo $dt | |
dt=`date -d "$dt 1 day" '+%Y%m%d'` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment