The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing a variable inside a variable to a function KingVikram UNIX for Dummies Questions & Answers 2 01-14-2008 05:28 PM
How to replace variable inside the variable mani_um Shell Programming and Scripting 31 08-09-2007 07:56 PM
Replace variable with a user defined variable ce124 Shell Programming and Scripting 1 04-15-2007 11:56 AM
Export command giving Variable Name vs the Value set for the Variable ParNone UNIX for Dummies Questions & Answers 2 04-03-2006 08:43 AM
ksh: A part of variable A's name is inside of variable B, how to update A? pa3be Shell Programming and Scripting 4 03-30-2005 08:29 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-05-2006
Registered User
 

Join Date: Aug 2005
Location: Paris
Posts: 75
variable under variable

Hello,

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

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

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

TY for your help
Reply With Quote
Forum Sponsor
  #2  
Old 09-05-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
What exactly are you trying to do?
Reply With Quote
  #3  
Old 09-05-2006
Registered User
 

Join Date: Aug 2005
Location: Paris
Posts: 75
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.
Reply With Quote
  #4  
Old 09-05-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
Code:
echo "value: \c"; read myvalue
cd "$myvalue"_TOP
Reply With Quote
  #5  
Old 09-05-2006
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
Try...
Code:
 eval cd \$${my_value}_TOP
Reply With Quote
  #6  
Old 09-06-2006
Registered User
 

Join Date: Aug 2005
Location: Paris
Posts: 75
Quote:
Originally Posted by jim mcnamara
Code:
echo "value: \c"; read myvalue
cd "$myvalue"_TOP

TY Jim but I know that, it's just a exemple, my target is to use $AA_TOP in a program.
Reply With Quote
  #7  
Old 09-06-2006
Registered User
 

Join Date: Aug 2005
Location: Paris
Posts: 75
Quote:
Originally Posted by Ygor
Try...
Code:
 eval cd \$${my_value}_TOP
TY Ygor, it works to use cd but have you got an idea to use this variable in a program ?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0