AnotherAlan
Technical User
Here’s what I’ve got as an example.
Set an array called ‘letters’ containing a, b and c.
Then run a for loop setting 3 arrays (a, b and c) to each contain word1, word2 and word3.
All works this far (you can check it with ‘set’ to see that it’s being defined. However, if you then want to do something with the array from within the for loop, I can’t use ${s[*]} as it thinks the array is called ‘s’. If I replace with $s, I get a syntax error. If I replace with ‘s’ with ‘a’, the contents of array ‘a’ are correctly displayed.
Line of death is "echo ${s[*]}"
#!/bin/ksh
set -A letters a b c
getorphans() {
for s in ${letters[*]} ; do
set -A $s word1 word2 word3
echo ${s[*]}
done
}
All help appreciated.
Thanks
Alan
Set an array called ‘letters’ containing a, b and c.
Then run a for loop setting 3 arrays (a, b and c) to each contain word1, word2 and word3.
All works this far (you can check it with ‘set’ to see that it’s being defined. However, if you then want to do something with the array from within the for loop, I can’t use ${s[*]} as it thinks the array is called ‘s’. If I replace with $s, I get a syntax error. If I replace with ‘s’ with ‘a’, the contents of array ‘a’ are correctly displayed.
Line of death is "echo ${s[*]}"
#!/bin/ksh
set -A letters a b c
getorphans() {
for s in ${letters[*]} ; do
set -A $s word1 word2 word3
echo ${s[*]}
done
}
All help appreciated.
Thanks
Alan