Skip to content

Instantly share code, notes, and snippets.

@idiomer
Last active July 1, 2020 06:57
Show Gist options
  • Save idiomer/89de932c50cf9736b01fed5dd0e5d99a to your computer and use it in GitHub Desktop.
Save idiomer/89de932c50cf9736b01fed5dd0e5d99a to your computer and use it in GitHub Desktop.
set -ex
# method 1
# [2020-01-01, 2020-01-31]
for i in {0..30}; do
thedate=$(date -I -d "2020-01-01 +$i days")
echo $thedate
done
# method 2
start_date="2020-05-01"
end_date="2020-05-31"
end_date=`date -d "-1 days ago $end_date" +%Y-%m-%d` # include end_date
while [ "$start_date" != "$end_date" ]; do
echo $start_date
start_date=`date -d "-1 days ago ${start_date}" +%Y-%m-%d`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment