I would like to put the result of the command date +"%Y.%m.%d" -d "yesterday"
in an environment variable.
I tried export YESTERDAY_DATE=date +"%Y.%m.%d" -d "yesterday"
but got an error stating the identifier is not correst.
How could I do it?
I would like to put the result of the command date +"%Y.%m.%d" -d "yesterday"
in an environment variable.
I tried export YESTERDAY_DATE=date +"%Y.%m.%d" -d "yesterday"
but got an error stating the identifier is not correst.
How could I do it?
export YESTERDAY_DATE=`date +"%Y.%m.%d" -d "yesterday"`
Alternatively, you can use this syntax:
YESTERDAY_DATE=$(date +"%Y.%m.%d" -d "yesterday")
See also here:
What's the difference between $(command) and `command` in shell programming?
Edit: Missing the capability of commenting the above solution: That's exactly why I prefer $() over ` - it's copy/pasteable (some systems have problems with backticks ...)