Say in bash I have:
c=3
b3=4
instead of:
echo $b3
what kinda of command to have output of "4" ? I tried below but couldn't.
echo $b($(c))
echo $b{!c}
echo $b${c}
echo ${d[$c]}
You can use an indirect reference for that:
$ c=3
$ b3=4
$ d=b$c
$ echo "${!d}"
4
Although usually instead of indirect references, arrays should be used when possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With