Created
July 4, 2013 15:34
-
-
Save huiliu/5928667 to your computer and use it in GitHub Desktop.
求得今天前的N天的字符串,如:"20130704"
This file contains hidden or 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 | |
| # Use shell calculate the date interval before today | |
| SECOND_TODAY=`date +%s` | |
| SECOND_PER_DAY=86400 | |
| INTERVAL=7 | |
| SEQ=`seq $INTERVAL` | |
| #set -x | |
| for i in $SEQ | |
| do | |
| DATE=`echo "$SECOND_TODAY - $SECOND_PER_DAY * ${i}" | bc` | |
| echo `date --date="@$DATE" +%Y%m%d` | |
| done | |
| #set +x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment