- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ${X_${Y}}
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2001 05:53 AM
07-29-2001 05:53 AM
${X_${Y}}
In shell can we do something of the kind
${X_${Y}} to print the value of X_2 when $Y=2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2001 06:54 AM
07-29-2001 06:54 AM
Re: ${X_${Y}}
While this seems intuitive. I don't think this will work. From the 'sh-posix' man pages in the parameter substitution discussion you can note: "The shell reads all the characters from ${ to the matching } as part of the same word, even if it contains braces or metacharacters."
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2001 07:43 AM
07-29-2001 07:43 AM
Re: ${X_${Y}}
Cheers...
Satish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2001 07:55 AM
07-29-2001 07:55 AM
Re: ${X_${Y}}
Another comment: You could consider setting and referencing your variables in an array.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2001 12:18 PM
07-29-2001 12:18 PM
Re: ${X_${Y}}
One other option you have is to set up associative arrays in awk so that your values are no referenced by numerical values but rather by strings such as "X1","X2","red","Blue".
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2001 05:48 PM
07-29-2001 05:48 PM
Re: ${X_${Y}}
The shell will try its best to explain the variable !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2001 06:54 PM
07-29-2001 06:54 PM
Re: ${X_${Y}}
eval print \"\$X_$Y\"
sometimes it is easier not to mess with the quotes and do something like
eval z=\$X_$Y
print $z
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2001 10:26 PM
07-29-2001 10:26 PM
Re: ${X_${Y}}
Try the following , it works :
echo ${X}_${Y}
Magdi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2001 03:46 AM
07-30-2001 03:46 AM
Re: ${X_${Y}}
set -A x
x[1]=jjjjjj
x[2]=yyyyyy
y=2
echo ${x[$y]}