Answer the question
In order to leave comments, you need to log in
How to use a variable in the name of another variable in bash?
There is a for i in 10 loop.
How can I use a variable whose name depends on $i in it?
Those. there are variables
disk_1
disk_2
and I want to use something like
$disk_$i in the loop
Answer the question
In order to leave comments, you need to log in
KVM_VM_DISK_SIZE_2='20000'
prefix='KVM_VM_DISK_SIZE_'
i=2
size=$(eval echo "\$$prefix$i")
echo $size
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question