![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a file in variable length format | Sarahb29 | UNIX for Dummies Questions & Answers | 2 | 04-22-2008 08:07 AM |
| creating a variable | rexmabry | UNIX for Dummies Questions & Answers | 3 | 02-22-2008 12:30 PM |
| creating array variable | scriptingmani | Shell Programming and Scripting | 2 | 06-28-2007 07:25 AM |
| Dynamically Creating and Printing to Files | Laud12345 | Shell Programming and Scripting | 0 | 03-02-2005 10:07 AM |
| creating a fixed length output from a variable length input | r1500 | Shell Programming and Scripting | 2 | 12-03-2003 10:09 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi !
I have the following situation - ##First variable variableA=JOB_A ##bunch of other variable JOB_A_RESTART=cleanupJobA JOB_B_RESTART=cleanupJobB JOB_C_RESTART=cleanupJobC now i need a script which would - 1. take the first variable 2. create a new variable name dynamically by appending "_RESTART" to the VALUE of the first variable. for example if variableA=JOB_B then the name of the new variable would be JOB_B_RESTART 3. give me the VALUE (not name) of the newly created variable. For example the value of JOB_B_RESTART would be cleanupJobB. I have been able to reach so far as step 2 but i have not been able to get the value of the newly created variable. My code is given below - variableA=JOB_A newVar=${variableA}_RESTART echo $newVar this last line echos "JOB_A_RESTART" whereas i want it to echo "cleanupJobA". Please helppppppppp .... thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Here is my similar question where vgersh99 provided this answer:
Code:
#!/bin/ksh
x=TESTVAR2
eval export "${x}_stdout=3"
print $TESTVAR2_stdout
# results in print $TESTVAR2_stdout
eval "print \$${x}_stdout"
Code:
eval "newVar=\$${variableA}_RESTART"
|
|
#3
|
|||
|
|||
|
that worked...thank you Thomas :-)
|
|||
| Google The UNIX and Linux Forums |