Skip to content

Instantly share code, notes, and snippets.

@komasaru
Created July 2, 2021 00:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save komasaru/31178555f140e1b459dae0aecf03984d to your computer and use it in GitHub Desktop.
Bash script to loop by date.
#!/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