Skip to content

Instantly share code, notes, and snippets.

@jumanjiman
Created July 15, 2019 13:24
Show Gist options
  • Save jumanjiman/9ceb132afee211d4166ca8ebc43016c4 to your computer and use it in GitHub Desktop.
Save jumanjiman/9ceb132afee211d4166ca8ebc43016c4 to your computer and use it in GitHub Desktop.
bash date arithmetic
#!/bin/bash
set -eEu
set -o pipefail
do_something() {
some_date=$1
echo "$some_date"
}
# https://stackoverflow.com/a/25701358
# (requires gnu date)
d="2014-06-29"
until [[ $d > 2014-07-03 ]]; do
do_something($d)
d=$(date -I -d "$d + 1 day")
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment