Skip to content

Instantly share code, notes, and snippets.

@jiacai2050
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiacai2050/16f132dec8f2bb0742c6 to your computer and use it in GitHub Desktop.
Save jiacai2050/16f132dec8f2bb0742c6 to your computer and use it in GitHub Desktop.
shell 打印指定范围内的日期
# 180天前是哪天
# date --date="-180 days" +%Y%m%d
sdate=2014-10-19
edate=2014-11-02
start=$(date -d$sdate +%s)
end=$(date -d$edate +%s)
while [[ $start < $end ]];do
echo `date -d@$start +%Y%m%d`
let start+=24*60*60
done
#参考:http://stackoverflow.com/questions/15621409/print-dates-in-date-range-linux
#输出
20141019
20141020
20141021
20141022
20141023
20141024
20141025
20141026
20141027
20141028
20141029
20141030
20141031
20141101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment