variable under variable

Hello,

In korn-shell, I want to call a variable formed by an other variable, is it possible ? :confused:

toto=tata ; export toto
tata_tmp=`pwd` ; export tata_tmp

pwd must be find with something like echo ${${toto}_tmp} => it doesn't work :frowning:

TY for your help

What exactly are you trying to do?

build the variable name from an other variable

for exemple :
AA_TOP=/tmp/my_dir/AA
AB_TOP=/tmp/my_dir/AB
AC_TOP=/tmp/my_dir/AC

echo "Value : \c" ; read my_value # is AA or AB or AC

Then, I want to call ${my_value}_TOP to set the good directory.

echo "value: \c"; read myvalue
cd "$myvalue"_TOP

Try...

 eval cd \$${my_value}_TOP 

TY Jim but I know that, it's just a exemple, my target is to use $AA_TOP in a program.

TY Ygor, it works to use cd but have you got an idea to use this variable in a program ?

would you like to do in this way....

AA_TOP=/tmp/my_dir/AA
AB_TOP=/tmp/my_dir/AB
AC_TOP=/tmp/my_dir/AC
read myval
#path=`pwd`
case "$myval" in

AA) path="$AA_TOP";;
AB) path="$AB_TOP" ;;
AC) path="$AC_TOP";;
*) ;;
esac
echo "dir is $path"

Yes but it must be work whatever the number of case may be :o

All you need is eval...

eval Target=\$${my_value}_TOP

hopefully this is what you need....and write it in a script

read my_value
new_val=`echo ${my_value}_TOP`
#And new_val is what you can use do your next job

cheers