Computing.Net > Forums > Unix > gamble with varible content

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

gamble with varible content

Reply to Message Icon

Name: arun.s
Date: November 21, 2005 at 23:04:42 Pacific
OS: unix
CPU/Ram: 256
Comment:

Hi all,

My problem is
say
y=z
x=y
now i want to assign the content of y to a varibal called var. var=$y is one way. but i dont want this method. i want assign the contne of y to var using variable x only

like
var=${$x} this is my assumption and this what exactly i want. i hope u understand my problem. reply as soon as possible..

thanks in advance....



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: November 21, 2005 at 23:45:03 Pacific
Reply:

One way ....

#!/bin/ksh

y=z
x=y

eval var=\$x
echo $var # should echo 'y'


0

Response Number 2
Name: Jim Boothe
Date: November 22, 2005 at 09:27:13 Pacific
Reply:

I think what arun.s wants is to assign to var the contents of a variable whose name is held in the variable x. So you do need the double evaluation:

y=z
x=y

eval var=\$$x
echo $var # will echo contents of $y


0

Response Number 3
Name: arun.s
Date: November 22, 2005 at 20:51:54 Pacific
Reply:

Hi,

thanks guys
especially thanks for jim for providing the solution..



0

Response Number 4
Name: Ibaul
Date: December 7, 2005 at 15:41:30 Pacific
Reply:

Hehe. Bash ariphmetic is dificult for use in shell.

Ibaul, wbr


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: gamble with varible content

list file contents alphabetically www.computing.net/answers/unix/list-file-contents-alphabetically/5501.html

Replace leading zeroes with spaces www.computing.net/answers/unix/replace-leading-zeroes-with-spaces/8157.html

error message in script www.computing.net/answers/unix/error-message-in-script/7025.html