0

I have environment variables TEST_GC_NAME, mini, fries and salmon2.

Their values are as follows:

export TEST_GC_NAME=hamburger
export mini=TEST
export fries=_GC_NAME 
export salmon2="\$$mini$fries"

When I echo salmon2, I get $TEST_GC_NAME.

Example:

echo $salmon2

result: $TEST_GC_NAME

How can I echo $salmon2 in such a way that I get hamburger.

pavbagel
  • 611
  • 2
  • 6
  • 17
  • This question has the "sh" tag. Do you really need a portable solution for this, or is the target shell only Bash? – l0b0 Sep 23 '20 at 02:41
  • if I set salmon2="echo \$$mini$fries", make another variable called salmon3=$(eval $salmon2), and finally echo $salmon3, that solves the issue – pavbagel Sep 23 '20 at 02:44

0 Answers0