Reputation: 421
I am trying to reference a variable within another one but its not working for me
$ bond0_enable='yes'
$ echo $bond0_enable
yes
$ i=0
$ echo $bond$i_enable
I want to reference the whole variable to read $i, how is this done please?
Upvotes: 0
Views: 48
Reputation: 289645
Like this, for example:
$ bond0_enable='yes'
$ i=0
$ d=bond${i}_enable
$ echo ${!d} <----- key point, ${!name} makes it
yes
Upvotes: 2