Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

How to echo a value of a var stored in another variable?

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 1 Week Ago
simpltyansh simpltyansh is offline
Registered User
 
Join Date: Mar 2014
Last Activity: 22 May 2017, 2:12 AM EDT
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Unix or Linux Question How to echo a value of a var stored in another variable?

I'm writing a shell script in AIX and using ksh.

I have a scenario where I have a variable A which stores $B.
so when i echo "$A" it prints $B

But I wish to print value stored in var b ie. \a\dir\res\

I wish to store \a\dir\res\ in a third variable C.
later I want to cd into that path : cd $C

How can I do it.

Last edited by simpltyansh; 1 Week Ago at 08:54 AM..
Sponsored Links
    #2  
Old Unix and Linux 1 Week Ago
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 28 May 2017, 4:43 AM EDT
Location: Aachen, Germany
Posts: 10,826
Thanks: 272
Thanked 3,324 Times in 3,061 Posts
Not sure I understand what you're after, and not sure either if that sort of redirection is the best way to do what you want.
You might want to try using eval to evaluate / expand variable twice, but this has its imponderabilia attached to it and may become dangerous, so be sure what exactly you're doing.
Another option is a sort of redirection that ksh offers, using ${!vname} expansion.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
List of All Users Stored in Variable hobscrk777 UNIX for Dummies Questions & Answers 1 05-17-2013 01:33 PM
How to check values stored in variable? ramsavi Red Hat 1 05-10-2013 04:32 AM
Variable not found error for a variable which is returned from stored procedure swap21783 Shell Programming and Scripting 4 03-22-2011 01:58 PM
How to define a variable with variable definition is stored in a variable? freddy1228 Shell Programming and Scripting 1 11-12-2009 03:39 AM
can i exectue a command stored in a variable.it goes like this Syms UNIX for Dummies Questions & Answers 2 11-01-2007 08:21 AM



All times are GMT -4. The time now is 04:44 AM.