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


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-17-2017   -   Original Discussion by simpltyansh
simpltyansh simpltyansh is offline
Registered User
 
Join Date: Mar 2014
Last Activity: 6 October 2017, 11:17 AM EDT
Posts: 14
Thanks: 9
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; 05-17-2017 at 09:54 AM..
Sponsored Links
    #2  
Old Unix and Linux 05-17-2017   -   Original Discussion by simpltyansh
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 17 November 2017, 6:42 AM EST
Location: Aachen, Germany
Posts: 11,616
Thanks: 320
Thanked 3,615 Times in 3,320 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
Closed

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 02:33 PM
How to check values stored in variable? ramsavi Red Hat 1 05-10-2013 05:32 AM
Variable not found error for a variable which is returned from stored procedure swap21783 Shell Programming and Scripting 4 03-22-2011 02:58 PM
How to define a variable with variable definition is stored in a variable? freddy1228 Shell Programming and Scripting 1 11-12-2009 04: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 09:21 AM



All times are GMT -4. The time now is 06:27 AM.