HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Korn Shell array syntax
Operating System - HP-UX
1827635
Members
3374
Online
109966
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
05-31-2003 12:15 AM
05-31-2003 12:15 AM
Hello all,
If anyone can answer this it would be here. So, here is the question:
I have a script in which I set up numerous arrays. To make a long story short, I am trying to create a function (to be later used repeatedly inside of a long case statement) in which I refer to an array by using a scalar variable. Like so,
function FunctionName
{
echo "${$variable}[@]"
}
What I am trying to do is echo all the elements of the array determined by $variable. The shell is not letting me do this, no matter how I quote it, or add more braces, etc.
I know this might sound like giberish the way I am explaining it. Can anyone help?
Thanks.
greg
If anyone can answer this it would be here. So, here is the question:
I have a script in which I set up numerous arrays. To make a long story short, I am trying to create a function (to be later used repeatedly inside of a long case statement) in which I refer to an array by using a scalar variable. Like so,
function FunctionName
{
echo "${$variable}[@]"
}
What I am trying to do is echo all the elements of the array determined by $variable. The shell is not letting me do this, no matter how I quote it, or add more braces, etc.
I know this might sound like giberish the way I am explaining it. Can anyone help?
Thanks.
greg
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2003 02:04 AM
05-31-2003 02:04 AM
Solution
Greg,
Here it is - take an idea from the line str='...' -
>>
$ cat k.sh
#!/usr/bin/ksh
set -A array `cut -d: -f1 /etc/passwd`
a="array" # setting array
str='${'$a'[@]}'
eval echo ${str[@]}
<<
To reference all element in a ksh-style array, use ${array[@]} not ${array}[@].
HTH.
- ramd.
Here it is - take an idea from the line str='...' -
>>
$ cat k.sh
#!/usr/bin/ksh
set -A array `cut -d: -f1 /etc/passwd`
a="array" # setting array
str='${'$a'[@]}'
eval echo ${str[@]}
<<
To reference all element in a ksh-style array, use ${array[@]} not ${array}[@].
HTH.
- ramd.
HPE Software Rocks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2003 04:12 PM
06-04-2003 04:12 PM
Re: Korn Shell array syntax
Thanks. Looks good. I assigned you 10 points but the drop down flipped back to 8 for some reason. I must have double clutched. The eval command was what I needed.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP