-1

Unable to echo $varible_$variable in csh

set a = temp

set value_${a} = 10

when trying to print the variable it isn't working. I need this to implement in nested for loop.

echo $value_$a value_: Undefined variable. (working with $value_temp)

Thanks in advance

Harry
  • 1
  • 1

1 Answers1

0

Use eval, with escape of the first $ when reading a variable:

% set a = temp
% eval set var_${a}=10
% echo $var_temp
10
% eval echo \$var_$a
10
% eval set result=\$var_$a
% echo $result
10
fork2execve
  • 1,561
  • 11
  • 16