In the second line, you are trying to execute $x date +m% . At this point, $ x will be installed in the year 2011. Now he is trying to run this command:
2011 date +%m
This is not what you want.
You can do it:
x=$(date +%Y) y=$(date +%m) echo "$x $y"
Or what:
x=$(date +%Y) x="$x $(date +%m)" echo "$x"
Or just use the final date format right away:
x=$(date "+%Y %m") echo $x
source share