JavaScript
x
f1="filename1";
i=1;
c=f$i
echo $c
What shell command should I use so that echo $c
returns “filename1” as the output?
Advertisement
Answer
You can use eval
to “nest” variable substitutions.
JavaScript
f1="filename1";
i=1;
eval c=${f$i}
echo $c