- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- array question
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
04-16-2002 10:46 AM
04-16-2002 10:46 AM
Thank you for your previous responses. Hopefully, it will be the last question.
Lets say, I have declared an array and have initialized it with the disks currently on the system:
diskArray[0]=/dev/dsk/c0...
diskArray[1]=/dev/dsk/c1
etc.
Currently, I can find out the biggest disk, so I do vgcreate on the biggest disk.
I will perform vgextend on all other disks in the array.
In the shell, how can I remove the value from the array? I know the index of the disk I want to remove from the array.
If I do diskArray[$biggestDiskIndex]="", would it work?
I am hesitant to the above, since for loop will go through all the disks left in the array and perform vgextend of them. If "" is encountered, I am afraid vgextend might fail!
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 10:55 AM
04-16-2002 10:55 AM
Re: array question
If you are referring to deleting an element of an array in 'awk', use:
# delete array[index]
The effect will be the same as if the element had never been allocated.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 10:58 AM
04-16-2002 10:58 AM
Re: array question
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 11:13 AM
04-16-2002 11:13 AM
Re: array question
XX[0]="Test 0"
XX[1]="Test 3"
XX[2]="Test 6"
XX[3]="Test 34"
Now let's suppose that you determine, XX[1] is the one you want to delete. I would simply move the last entry into that position and then do an unset on the last array member. ${#XX[*]} will then be reduced by 1. The array is no longer order as before but who cares. Of course, in the special case that the element that you need to delete is the last element then simply unset it and your are done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 11:25 AM
04-16-2002 11:25 AM
Re: array question
Thank you for your response.
I was thinking of replacing item to be removed with the last item. Unfortunately, I don't know the length of an array. I doubt shell has function such length(array), so I guess I will need to do a loop to determine the length of an array...?
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 11:34 AM
04-16-2002 11:34 AM
SolutionLIMIT=$(( ${#arrayname[*]} - 1)) # if the subscripts start at 0
I=0
while [ ${I} -le ${LIMIT} ]
do
echo "${I} --> ${arrayname[${I}]}"
I=$(( ${I} + 1 ))
done