[user@mymachine folder]$ echo `date --date=tomorrow +%Y%m%d`
[user@mymachine folder]$ echo `date -d=tomorrow +%Y%m%d`
date: invalid date `=tomorrow'

I'm using Centos 5 if that makes any difference.

  • 7
    Short options are separated from their argument by a space: date --date=tomorrow +%Y%m%d date -d tomorrow +%Y%m%d Aug 1 '16 at 18:52
  • Thank you. Most helpful. I can see that you are correct on my machine.
    – seanmus
    Aug 1 '16 at 18:54
  • 1
    @user4556274: Post that as an answer as it is obviously valid. Aug 1 '16 at 19:01
  • 1
    (1) Why are you saying echo `date --date=tomorrow +%Y%m%d` instead of just date --date=tomorrow +%Y%m%d?   (2) If you have a reason to use command substitution, you might want to change `…` to $(…) just for clarity — see this, this, and this. Aug 3 '16 at 22:11

The short options or unix style options are usually separated from its argument using a space, but space is not strictly required in some cases

For instance

echo `date -dtomorrow +%Y%m%d`


echo `date -d tomorrow +%Y%m%d`

would work just fine

However in case of,

echo date -d=tomorrow +%Y%m%d

=tomorrow is considered the argument to d but it doesn't make a valid date string

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.