|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to get an Indirect Variable Value..?
Hi, I've got a small problem. If varible A stores "B" and Variable B stores C, How to get the value of variable B by using only Variable A..? I tried the following but didnt work pease help.. Code:
$ var1=vikram $ echo $var1 vikram $ vikram=sampath $ echo $vikram sampath $ echo $`echo $var1` $vikram In the above code Why i'm getting "$vikram" when i was expecting "sampath" (because $vikram=sampath) Please help me the right way to decode in the above situation.. thanks Vikram shetty |
| Sponsored Links | ||
|
|
|
#2
|
||||
|
||||
|
See the following code. Code:
var1=vikram echo $var1 vikram=sampath echo $vikram eval echo \$$var1 [or] Code:
eval echo \$$(echo $var1) [or] Code:
eval echo \$`echo $var1` |
|
#3
|
||||
|
||||
|
Code:
eval result=\$$var1 echo $result It will print the word sampath |
|
#4
|
|||
|
|||
|
thanks u very much ungalnanbu and selvan..
Its working fine.. Could you please pass on me any material that describes the above behaviour of variables.. thanks Vikram shetty |
|
#5
|
||||
|
||||
|
Indirect References.
http://www.linuxjournal.com/article/7385 Please go through the above URL. This will help you to know about variables. Last edited by thillai_selvan; 03-12-2010 at 01:31 AM.. |
|
#6
|
||||
|
||||
|
Refer the following links.
Advanced Bash-Scripting Guide Very Simple Bash Scripts Linux Shell Scripting Tutorial - A Beginner's handbook |
|
#7
|
|||
|
|||
|
Thank you very much guys..
warm regards Vikram Shetty |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 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 |
| Insert a line including Variable & Carriage Return / sed command as Variable | lowmaster | Shell Programming and Scripting | 2 | 05-19-2009 11:26 PM |
| Length of an indirect variable | gone_bush | Shell Programming and Scripting | 0 | 03-28-2006 07:17 PM |
| Compound indirect variable references | tkrussel | UNIX for Advanced & Expert Users | 5 | 08-21-2005 10:03 AM |