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

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

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
seanmus
  • 141
  • 5
  • 7
    Short options are separated from their argument by a space: `date --date=tomorrow +%Y%m%d` `date -d tomorrow +%Y%m%d` – user4556274 Aug 01 '16 at 18:52
  • Thank you. Most helpful. I can see that you are correct on my machine. – seanmus Aug 01 '16 at 18:54
  • 1
    @user4556274: Post that as an answer as it is obviously valid. – Julie Pelletier Aug 01 '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](http://unix.stackexchange.com/q/5778/80216), [this](http://unix.stackexchange.com/q/147838/80216), and [this](http://unix.stackexchange.com/q/104119/80216). – G-Man Says 'Reinstate Monica' Aug 03 '16 at 22:11

1 Answers1

3

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`

and

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

sjsam
  • 1,576
  • 2
  • 13
  • 22