Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can give the day for today in a command:

TODAY=`date +%Y.%m.%d.`

but how can I give out the next 3 or X days in a command? (Ubuntu 12.04)

share|improve this question
up vote 1 down vote accepted

See the man page for the date command and look at the -d option:

 % date -d '+1 day'
 Mon Jul 15 21:51:06 PDT 2013
 % date
 Sun Jul 14 21:51:16 PDT 2013

I'd also suggest running:

 info date

for more explicit information.

share|improve this answer
For GNU date, the info on "1 day" etc, is in the info page, and not found in the man page on my system. – jordanm Jul 15 '13 at 4:53
however the man page has a small example with --date (aka -d) if you read it. My specific example is not present. – mdpc Jul 15 '13 at 4:55
BTW, the man page references going to the info page for more information. – mdpc Jul 15 '13 at 4:58

If you have GNU date available, you can use the following to show today and next 3 days:

while [ $x -lt 4 ]; do
   date -d "$x days" '+%Y.%m.%d.'
share|improve this answer
THanks you very much! – gasko peter Jul 15 '13 at 6:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.