generate dynamic variable in unix
S1= 23450
J=1 I would like to get print value as below echo $SJ 23450 s2= 23490 J=2 echo $S2 23490 but how can I achive in unix shell using echo statement, I am using such logic in loop and J is the counter. |
What you are asking for can be done in bash but is messy and potentially dangerous. An array solution would be better:
Code:
S[1]=23450 |
I think you need the eval
try eval echo \$S$J (and be careful s2 and S2 are not the same) |
All times are GMT -5. The time now is 10:56 PM. |