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

Thread Tools Search this Thread Display Modes
Old 05-17-2017
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
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 08:54 AM..
Sponsored Links
Old 05-17-2017
RudiC RudiC is online now Forum Staff  
Join Date: Jul 2012
Last Activity: 18 October 2017, 8:58 AM EDT
Location: Aachen, Germany
Posts: 11,473
Thanks: 309
Thanked 3,556 Times in 3,273 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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:07 AM.