bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
Run the following and I'm wondering if there are any other cool ways to print / get the values (than using eval / requiring to create another variable).
a=giga;
b=$a;
echo a=$a --equals-- b=$b;
echo;
c=\$a;
eval d_${a}_version=1.1.1; ## I want to use this format. Use case: where possible values for 'a' are more than 100 and I don't want to create 100+ individual variables in my script.
echo c=$c;
eval echo "c\'s \(dereferenced_value\)=$c"; ## Had to use eval to de-reference / get to a's value.
echo "d_giga_version = $(eval echo \$d_${a}_version)";
d_real_ver=d_${a}_version; ## Had to create another variable (wondering if there's another way to dereference d_giga_version variable's value.
echo "d_real_ver = ${!d_real_ver}";
echo -e "\n\n-- HOW can i get value of 'c' == "giga" without using eval --OR--\n-- How can i get the value '1.1.1' (without requiring to create another new variable like \${d_real_ver}?\n\n"
It'll output:
a=giga --equals-- b=giga
c=$a
c's (dereferenced_value)=giga
d_giga_version = 1.1.1
d_real_ver = 1.1.1
-- HOW can i get value of 'c' == giga without using eval --OR--
-- How can i get the value '1.1.1' (without requiring to create another new variable like ${d_real_ver}?
PS: My post/question that I'm trying to achieve is different than Bash - variable variables this post uses another variable to derefernece (see last 2 lines in output) for my questions.