- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: ksh set -A negative value problem
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
10-10-2004 06:40 PM
10-10-2004 06:40 PM
How can we use negative values on ksh shell arrays.
When I tried to use as,
TEST="-1 -2 -3"
set -A ARR $TEST
ksh: set: -1: unknown option
But it is working for,
TEST="1 -2 -3"
set -A ARR $TEST
echo ${ARR[0]} ${ARR[1]} ${ARR[2]}
But on sh, bash it will not be problem there.
Share you knowledge.
Thanks,
Muthu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2004 06:54 PM
10-10-2004 06:54 PM
Re: ksh set -A negative value problem
"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."
RGDS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2004 07:19 PM
10-10-2004 07:19 PM
Re: ksh set -A negative value problem
that was good reference note.
But ksh shell array is supporting second, n index of array's with negative values there.?
Can we use any other method to index array values with negative values there.?
Thanks for your time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2004 07:31 PM
10-10-2004 07:31 PM
Re: ksh set -A negative value problem
have you tried TEST="\\-1 -2 -3"
?
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2004 07:48 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2004 08:05 PM
10-10-2004 08:05 PM
Re: ksh set -A negative value problem
I show my tries...
In effect:
$ ksh
$ unset PLUTO
$ set -A PLUTO "1" "2" "3"
$ echo ${PLUTO[0]} " " ${PLUTO[1]} " " ${PLUTO[2]}
1 2 3
$ unset PLUTO
$ set -A PLUTO "1" "-2" "3"
$ echo ${PLUTO[0]} " " ${PLUTO[1]} " " ${PLUTO[2]}
1 -2 3
$ unset PLUTO
$ set -A PLUTO "-1" "2" "3"
ksh: -1: bad option(s)
So it seems only the first value don't have a minus sign.
But look this strange behavior:
$ unset PLUTO
$ typeset -i PLUTO[0]=1
$ typeset -i PLUTO[1]=1
$ typeset -i PLUTO[2]=1
$ echo ${PLUTO[0]} " " ${PLUTO[1]} " " ${PLUTO[2]}
1 1 1
$ PLUTO[0]=${PLUTO[0]}-1
$ echo ${PLUTO[0]} " " ${PLUTO[1]} " " ${PLUTO[2]}
0 1 1
$ PLUTO[0]=${PLUTO[0]}-1
$ echo ${PLUTO[0]} " " ${PLUTO[1]} " " ${PLUTO[2]}
4294967295 1 1
So I think, when you try to assing
set -A PLUTO "-1" "2" "3"
or
set -A PLUTO "1" "-2" "3"
you assign a string value and not a numeric value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2004 08:12 PM
10-10-2004 08:12 PM
Re: ksh set -A negative value problem
$ unset PLUTO
$ set -A PLUTO "--" "-1" "2" "3"
$ echo $(( ${PLUTO[0]} - 1))
-2
:-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2004 08:55 PM
10-10-2004 08:55 PM