![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Dynamic variable values | ronnie_uk | UNIX for Dummies Questions & Answers | 3 | 07-11-2008 10:03 AM |
| comparing values of same variable | coolkid | Shell Programming and Scripting | 2 | 05-27-2008 06:45 PM |
| getting values from variable in a loop | kriuz | Shell Programming and Scripting | 3 | 01-22-2008 05:50 PM |
| Substitute variable values | John Rihn | Shell Programming and Scripting | 12 | 03-15-2006 10:40 PM |
| Storing values in variable | matrixmadhan | Shell Programming and Scripting | 1 | 04-01-2005 02:56 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to get the values from a variable having variable name
In shell script how to do the following .......................
For example I have following 3 variables VARIABLE_DYNAMIC JOB_NP_22="ABCD" JOB_NP_88="HELLO" based on the value in VARIABLE_DYNAMIC the particular variable value should be displayed -------------------------------------------------------------- (I) If value of VARIABLE_DYNAMIC="JOB_NP_21" so by some way i should get value of "JOB_NP_21" i.e ABCD as output (II) If value of VARIABLE_DYNAMIC="JOB_NP_88" so by some way i should get value of "JOB_NP_88" i.e HELLO as output we can retrive variable directly $VARIABLE_DYNAMIC but as the value in VARIABLE_DYNAMIC is coming dynamically..... i am facing problems in retriving values of the variable (JOB_NP_21 / JOB_NP_88) Please tell me how to do that Last edited by anilacharya4u; 09-19-2008 at 06:44 AM.. |
|
||||
|
hi era / subhendu ,
can u please tell me how do i assign the value which i get from this eval echo \$$VARIABLE_DYNAMIC to a variable See the JOB_NP_22 and JOB_NP_88 are actually arrays... The actual strucure of my variable would be JOB_NP_22[0]=a,b JOB_NP_22[1]=c,d JOB_NP_88[0]=m,n JOB_NP_88[1]=o,p i will get these values and loop through the elements ... Basically the String JOB_NP_22 and JOB_NP_88 will be created partly by "JOB_NP" ( this is hard coded ) and 22 /88 passed as paramters so its a combination of 2 However my hardcode variable loop works for (( cnt = 0 ; cnt < ${#JOB_NP_22[@]} ; cnt++ )) do echo ${JOB_NP_22[cnt]} done Need to replace this hardcoded loop and make it dynamic So please tell me how to assign it to an array and use the array across in my code for looping Last edited by anilacharya4u; 09-19-2008 at 07:19 AM.. |
|
||||
|
Hi,
The array looping for JOB_NP_22 / JOB_NP_88 part is done... Problem is with the initial part for retriving values i.e taking value of variable name in VARIABLE_DYNAMIC String Can the value which we get from this eval echo \$$VARIABLE_DYNAMIC be put in array It is required in the array for loopingthrough elements |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|