Bash Get length of variable string whose name is expanded by another variable

Viewed 40

Case Scenerio:

start=1

va$start=123

for ((i=0; i < ${#$(echo va$start)}; i++)); do commands; done

Error : Bad Substitution
How to expand length of va$start variable using ${#$(echo va$start)} --> ${#va1}

1 Answers
start=1
eval va$start=12345
tmp=va$start
len=${!tmp}
for ((i=0; i < ${#len}; i++)); do commands; done
Related