1

I have something like this:

$CORSAIR_TYPE="good"
$CASE="CORSAIR"
...
$local temp_type=${CASE}_TYPE
echo ${!temp_type}

This gives me the value of the variable CORSAIR_TYPE, which is "good". Is there a way of doing this without creating the temp_type variable? What would I replace echo ${!temp_type} with?

Thanks

Agustin Meriles
  • 4,866
  • 3
  • 29
  • 44
halexh
  • 3,021
  • 3
  • 19
  • 19
  • 1
    yes, `eval echo '$'"${CASE}_TYPE"` or something like that. – n. m. could be an AI Mar 26 '13 at 12:40
  • With `${!foo}`, `foo` has to be a variable. So, no, at least with the code you've given, not really. Also, there is no situation where I'd go with any `eval` solution just to avoid creating a single temporary variable. – jedwards Mar 26 '13 at 15:09

1 Answers1

0

For anyone else stumbling across this post, this is one way I found of doing it:

echo $(eval echo $`echo ${CASE}_TYPE`)
halexh
  • 3,021
  • 3
  • 19
  • 19