I am stuck with the below code and any help would be greatly appreciated:
I am trying to assign contents inside a dynamically generated variable to another variable. But instead of the value of the variable getting assigned, I could see that the variable name is getting assigned. I tried (echo/eval/!) but nothing is working. Could someone please help me with the solution?
Objective: To assign value 24 (saved under variable msd_ext_len) to final_count variable.
Variable Declaration
iter_val=1
var_1="msd_ext"
msd_ext_len=24
Code:
eval "final_count"=\${var_${iter_val}}_len
Output --> msd_ext_len
Expected Output --> 24
If I add one more line of code as shown below along with above code and I am getting the output:
count_val=${!final_count}
But can these 2 lines of code be clubbed into a single line of code?