|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
While ...loop
Code:
#!/usr/bin/ksh
totalInstance=3
c=1
SID=SID
SID_1=BOYISH
SID_2=EAGALE
SID_3=PLUNE
while [ c -le $totalInstance ]
do
BDUMP_DIR="${SID}_${c}"
echo "$BDUMP_DIR"
c=`expr $c + 1`
echo "$c"
donehaving problem printing the value of my var SID_1, SID_2, SID_3 instead the output printed out is just SID_1 SID_2 SID_3 i need the value assign to SID_1..3 . |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
c is a variable, you need a $ before it. Code:
while [ "$c" -le .... ... c=$((c + 1)) ... done |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Hey, try this, Code:
.. while [ $c ... .. Cheers, Ranga
|
|
#4
|
|||
|
|||
|
erm..i made the changes u recomanded still not able to get the value assign to SID_1 , SID_2 , SID_3
|
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Code:
while [ $c -le $totalInstance ]
do
BDUMP_DIR="${SID}_${c}"
eval echo "\$$BDUMP_DIR"
c=$((c + 1))
echo "$c"
done |
| The Following User Says Thank You to Scott For This Useful Post: | ||
redologger (01-07-2013) | ||
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
You need either sth corresponding to bash indirection (don't know in ksh - ${!vname}?) or use
eval to assign to BDUMP_DIR.
|
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
what happen if is: Code:
BDUMP_DIR=/home/John/admin/"${SID}_${c}"/bdumpseem like Code:
eval echo "\$$BDUMP_DIR" doesn't produce /home/john/admin/plune ---------- Post updated at 09:31 PM ---------- Previous update was at 09:15 PM ---------- Quote:
is ok guys figure it out to be: Code:
BDUMP_DIR=/home/John/admin/"\$${SID}_${c}"/bdump---------- Post updated 01-08-13 at 01:48 AM ---------- Previous update was 01-07-13 at 09:31 PM ---------- but i can't figure out why there is a $ infront when i Code:
eval echo "\$$BDUMP_DIR" $/home/john/admin/plune Last edited by Scrutinizer; 01-08-2013 at 02:11 AM.. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Array Variable being Assigned Values in Loop, But Gone when Loop Completes??? | mrm5102 | Shell Programming and Scripting | 5 | 10-19-2012 10:00 AM |
| HELP PLS - calling function in a while loop ends the loop ?? | newbie_01 | Shell Programming and Scripting | 3 | 05-29-2012 04:38 PM |
| BASH loop inside a loop question | rethink | Shell Programming and Scripting | 4 | 09-15-2010 07:58 AM |
| Null Handling in Until loop. . .loop won't stop | brandono66 | Shell Programming and Scripting | 4 | 11-24-2009 03:57 PM |
| Using variables created sequentially in a loop while still inside of the loop [bash] | DeCoTwc | Shell Programming and Scripting | 2 | 06-23-2009 04:59 PM |
|
|