How to generate a list of dates from the shell (bash)

Here is a shell script that will generate the dates of the monday’s within the given range. It requires bash and the GNU version of the date command (gdate in my case). Currently it works only if the date format allows to compare date by comparing strings, but you can easily adapt it if required.


start=`$DATE +$FORMAT -d "2013-05-06"`
end=`$DATE +$FORMAT -d "2013-09-16"`
while [[ "$now" < "$end" ]] ; do
  now=`$DATE +$FORMAT -d "$now + 1 week"`
  echo "$now"
This entry was posted in Linux. Bookmark the permalink.

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s