I have an array in ksh script and I want to extend it
When I try a test script
it works exactly as I would wish. However, if the array members have spaces in them i.e.
then the first three members are re-interpreted as six separate items when the array is rebuilt to add the fourth element. and the output looks like
There must be a better way of adding a new member to a ksh array but the IBM web pages don't really help. Any pointers please?
Ceci n'est pas un signature
Columb Healy
When I try a test script
Code:
#!/bin/ksh
set -A arr one two three
index=0
while [[ $index -lt ${#arr[*]} ]]
do
echo ${arr[$index]}
(( index += 1 ))
done
set -A arr ${arr[*]} four
index=0
while [[ $index -lt ${#arr[*]} ]]
do
echo ${arr[$index]}
(( index += 1 ))
done
Code:
#!/bin/ksh
set -A arr "part one" "part two" "part three"
index=0
while [[ $index -lt ${#arr[*]} ]]
do
echo ${arr[$index]}
(( index += 1 ))
done
set -A arr ${arr[*]} "part four"
index=0
while [[ $index -lt ${#arr[*]} ]]
do
echo ${arr[$index]}
(( index += 1 ))
done
Code:
part one
part two
part three
part
one
part
two
part
three
part four
There must be a better way of adding a new member to a ksh array but the IBM web pages don't really help. Any pointers please?
Ceci n'est pas un signature
Columb Healy