I am trying to do a code walk through a badly written bash script.
I have come across this statement:
FOOBAR_NAME=`date +WeekNo.%W`
There are no prior declarations of any of the RHS variables in the script, lines preceding this statement.
So my question is:
What does FOOBAR_NAME resolve to, when it is used a few lines down in the script as $FOOBAR_NAME ?
There are no variables being referenced in the RHS.
The backtick operator (“
) evaluates its contents and returns the output, similar (identical?) to$(). It's a quick way to write aneval` (in other languages).Type
date +WeekNo.%Win a shell. What is printed (in stdout, with newlines collapsed) is what will be stored inFOOBAR_NAME.Note that the evaluation occurs only once, which is during the assignment.
dateisn’t executed each time you referenceFOOBAR_NAME.