- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: typeset -A
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
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
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
тАО02-17-2004 08:37 AM
тАО02-17-2004 08:37 AM
typeset -A foo
foo = ([z]=a [y]=b)
is for ksh to use to assign associative array. I tried on hpux and got
ksh: typeset: bad option(s)
on linux, it says
ksh: typeset -A: unknown option.
What's wrong?
Jun Z
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2004 08:49 AM
тАО02-17-2004 08:49 AM
Re: typeset -A
For example,
set -A arry red orange yellow green blue indigo violet
echo ${arry[0]}
$ red
echo ${arry[6]}
$ violet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2004 08:52 AM
тАО02-17-2004 08:52 AM
Re: typeset -A
In ksh & sh-posix you'd use
set -A array_name value1 value2 ....
to set a one-dimensional array.
That's all the shell can handle AFAIK.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2004 08:53 AM
тАО02-17-2004 08:53 AM
Re: typeset -A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2004 09:07 AM
тАО02-17-2004 09:07 AM
Re: typeset -A
array[0]=tom
array[1]=jane
print ${array[0]}
tom
print ${array[1]}
jane
Elena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2004 01:39 PM
тАО02-17-2004 01:39 PM
Solutionif it did you'd do something like this:
typeset -A color
color[apple]=red
color[banana]=yellow
...etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-18-2004 01:18 AM
тАО02-18-2004 01:18 AM
Re: typeset -A
What happens to you when you type in ksh
typeset -A foo
?
Jun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-18-2004 02:00 AM
тАО02-18-2004 02:00 AM
Re: typeset -A
Simply
/usr/bin/ksh typeset: bad option(s)
set is your huckleberry....
jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-18-2004 02:14 AM
тАО02-18-2004 02:14 AM
Re: typeset -A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-18-2004 02:47 AM
тАО02-18-2004 02:47 AM
Re: typeset -A
set [+-]A arrayName args
the values are assigned sequentially from zero and has a maximum of 1024 elements, 1023 is the largest index.
use -A to unset the array prior to the assignment.
#assigns f[0]=1 and f[1]=4
set -A f 1 4
#assigns f[0]=5, but f[1] is left alone
set +A f 5
if you really need to use associative arrays you'll have to use a tool that supports them,
/usr/dt/bin/dtksh, awk, perl, etc.