- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- 2 dimensional Array in Shell script
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
Discussions
Discussions
Discussions
Forums
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
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
тАО11-11-2002 05:57 PM
тАО11-11-2002 05:57 PM
I have a question about using the 2 dimensional array in Shell script? Can anyone tell me how to implement the 2 dimensional array through Ksh or sh ?
Much appreciated if you can provide additional link for reference.
Many thanks,
Chris,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2002 06:38 PM
тАО11-11-2002 06:38 PM
SolutionI don't think you can do it in either ksh or in the Posix shell. Here is a URL to the HP-UX 11.00 commands docs for 'sh-posix' and 'ksh'. The snippet of text is found in the descriptions for both 'ksh' and 'sh-posix':
http://docs.hp.com/hpux/onlinedocs/B2355-90680/B2355-90680.html
"The shell supports a limited one-dimensional array facility. An element of an array parameter is referenced by a subscript. A subscript is denoted by a [, followed by an arithmetic expression, followed by a ]. See the "Arithmetic Evaluation" subsection. To assign values to an array, use set -A name value .... The value of all subscripts must be in the range of 0 through 1023. Arrays need not be declared. Any reference to a named parameter with a valid subscript is legal and an array is created if necessary. Referencing an array parameter without a subscript is equivalent to referencing the first element."
Now, someone might know of some trick to access a two dimensional array in a shell script, but I don't know of any way to do it. I think the question has been posed here on the forum before, but I couldn't find it anywhere.
I think you can do two dimensional arrays in 'awk', but I haven't tried it. You can do it in Perl, which is what I would suggest, especially since it is so easy to get Perl for HP-UX and install it.
I'm just curious, but what problem are you trying to solve with the two dimensional arrays?
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2002 07:10 PM
тАО11-11-2002 07:10 PM
Re: 2 dimensional Array in Shell script
perl
perl will run many times faster than anything you can implement in sh/ksh. And yes, it has arrays!
If you must continue with "two" dimensional array's in sh/ksh, then you will have to use two different variable names and just fake it!
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2002 10:37 PM
тАО11-11-2002 10:37 PM
Re: 2 dimensional Array in Shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2002 10:37 PM
тАО11-11-2002 10:37 PM