Skip to content

Instantly share code, notes, and snippets.

@mpapi
Created September 25, 2011 02:49
Show Gist options
  • Save mpapi/1240159 to your computer and use it in GitHub Desktop.
Save mpapi/1240159 to your computer and use it in GitHub Desktop.
A quick shell script to generate ranges of dates
#!/bin/bash
LIMIT=${1:-1}
FORMAT=${2:-"%Y-%m-%d"}
if [[ $LIMIT -lt 0 ]]
then
SEQ=$(seq 0 -1 $(( $LIMIT + 1 )))
else
SEQ=$(seq 0 $(( $LIMIT - 1 )))
fi
for i in $SEQ
do
date -d "+$i days" +$FORMAT
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment