Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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

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

Your Answer

 
discard

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.