Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
By using a csh, I want to address a variable content whose name is/matches the content of a given other variable.
i.e.
set name=´sam´
set ${name}_age=´27´
So, by typing: echo ${name}_age
I correctly obtain: sam_age
By typing: echo $sam_age
or echo ${sam_age}
I correctly obtain: 27
But how can I obtain "27" by using ${name} instead of "sam"?
The following instruction does not work!
echo ${`echo ${name}_age`}
Any helps will be accepted!
Thanks a lot!

The eval command is typically used for this:
#!/bin/csh
set name='sam'
set eval ${name}_age='27'echo "sam is: ${sam_age}"

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |