Created
September 25, 2011 02:49
-
-
Save mpapi/1240159 to your computer and use it in GitHub Desktop.
A quick shell script to generate ranges of dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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