Skip to content

Instantly share code, notes, and snippets.

@chluehr
Created April 26, 2012 20:28
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save chluehr/2502805 to your computer and use it in GitHub Desktop.
Save chluehr/2502805 to your computer and use it in GitHub Desktop.
Bash: Loop over dates
#!/bin/bash
now=`date +"%Y-%m-%d" -d "05/06/2012"`
end=`date +"%Y-%m-%d" -d "05/23/2012"`
while [ "$now" != "$end" ] ;
do
now=`date +"%Y-%m-%d" -d "$now + 1 day"`;
echo $now
done
@tanzyy
Copy link

tanzyy commented Mar 28, 2017

on Mac, use -v option.

$(date -v -1d +"%Y-%m-%d")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment