Skip to content

Instantly share code, notes, and snippets.

@komasaru
Created July 2, 2021 00:23
Embed
What would you like to do?
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