Home > HOWTOs > Date Range in Shell script

Date Range in Shell script

Date in formar yyyymmdd
Output as 

20130101 20130102
20130102 20130103  

 startdate=20130315
 enddate=20130414
 
 curr=”$startdate”
 while true; do
     #echo “$curr”
     [ “$curr” \< "$enddate" ] || break
     next=$( date +%Y%m%d –date “$curr +1 day” )
     echo “$curr $next”
     curr=$next
 done
Advertisements
Categories: HOWTOs
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: