How to print the next week using the date command ?

date +"This is week: %U of %Y, Sprint: %y(W%U-%U)"

The output should be

This is week: 04 of 2017, Sprint: 17(W04-05)

Instead of

This is week: 04 of 2017, Sprint: 17(W04-04)
  • If the existing answer solves your problem, please consider accepting it via the checkmark. Thank you! – Jeff Schaller Apr 13 '17 at 23:25

With GNU date:

date +"This is week: %U of %Y, Sprint: %y(W%U-$(date -d 'now + 7 days' +%U))"


date +"This is week: %U of %Y, Sprint: %y(W%U-$(date -d 'next week 12:00' +%U))"
  • 1
    Would be better as date -d 'next week 12:00' in timezones that have DST. For instance, in mainland UK, faketime '2017-03-19 23:30' date +%W-%F-%R outputs 11-2017-03-19-23:30 and faketime '2017-03-19 23:30' date -d 'next week' +%W-%F-%R outputs 13-2017-03-27-00:30 – Stéphane Chazelas Jan 23 '17 at 21:28
  • I'm all for improvement! so amended – Jeff Schaller Jan 23 '17 at 21:32
  • I wonder how much time DST saves. I don't know if it is big or small, but I do know the sign (-). – ctrl-alt-delor Jan 23 '17 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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