Array question

Hi all,
I have a question does anyone know if it is possible to push or pop an array in the ksh environment? Could anyone give me a hint, because I am trying to merge 2 server files together and there are some names in the server is not proper anymore.

Thank you in advance.

define "push or pop"? - you can iterate or increment or decrement the element(s) of an array. We need more information on what you want.

think of an array as your 'stack' and implement your own functions:

  1. push - slide array elements UP and insert a new element in location '0'
  2. pop - remove the element '0' and slide the array elements DOWN

The question is: why do you need to do this?

Hopefully the section of the codes below will help me to explain what i am trying to do

--------------------------------------------------------------------------

typeset -i count=0
set -A array1 ab bx cd ef
# "ab bx cd ef" are the list of servers
while [ count -le ${#array1[@]} ] && [ count -ge 0 ]
do
# testfunction will return
# 1 = pass
# 0 = fail
test=$(testfunction array1[count])
if [[ $test -eq 1 ]]; then
echo "${array1[count]}_server"
fi
--------------------------------------------------------------------------

Above are the section of codes that I am having problem, when I ran this scripts, it will return the server name that I wanted along with the server name that I don't want
Output:
ab_server
bx
cd_server
ef_server

So are there some way to pop "bx" from the server list? I mean after it goes through the (testfunction). Thank you.

Well, figured it out. There are no push/pop for array in UNIX KSH. What I had done is that I cat the server names to a file and use sed to do my job, and then append those server name back to the array again. Hope this trick would help other when they want to do push/pop with an array.