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.
f1="filename1";
i=1;
eval c=${f$i}
echo $c
f1="filename1"; i=1; c=f$i echo $c
What shell command should I use so that echo $c returns “filename1” as the output?
You can use eval to “nest” variable substitutions.
f1="filename1";
i=1;
eval c=${f$i}
echo $c