Hi,
I have defined 2 variables in a ksh file something like below.
x=abc
y=x
Now, I want to get abc printed using y.
I have tried echo $"$y" and I am getting $x but where as I am expecting abc.
Please suggest.
(something like pointer pointer in C language)
gary_w
2
I think you are looking for something like this using eval:
#!/usr/dt/bin/dtksh
x=abc
y=x
eval z=\$${y}
print "x: $x"
print "y: $y"
print "z: $z"
# Prove the value of y has not changed:
print "\ny: $y"
exit 0
Output:
$ evaltest
x: abc
y: x
z: abc
y: x
$
eval scans the line twice, first replacing ${y} with it's value, 'x' so then z is equal to $x.
Thanks for your reply!!! it works...