Statement: "$k"_Id_avg="$(grep -i "$k"_Id_avg file.txt)" and $k is a loop variable. Now I want to print the value stored in the above variable, how can I do it? I have tried echo "$k"_Id_avg but it prints only the variable name and replaces $k with the current loop value. eg: NM_Id_avg
1 Answer
I would suggest something like:
varname="$k"_Id_avg echo ${!varname}