I don't understand why this doesn't work:
TEXT="blah" echo $TEXT #echoes nothing
I thought it might be because echo is a builtin, so I tried this:
TEXT="blah" `which echo` $TEXT #still nothing
What am I missing?
The shell expands the variables before it runs the command, even before it runs the assignments.
Cf.
text=blah ; echo $text
or
text=blah eval 'echo $text'
The first one works because the assignment is run as a separate command. The second one works because $text
is single-quoted which prevents its expansion when shell is processing the command; when eval
is later running, the variable already has the value assigned.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments