Bash: Help with output from a for loop

Hi,

Sorry I'm new to shell scripting..

my loop is as follows:

 
let i=0
for item in ${APPSARRAY[@]}
do
          #..some code to get a unique value called $result
          let i=i+1
done

What I want to do is within the for loop, create a comma seperated list:

output=$result,$result...$result(n)

which I can then use outside of the loop...Can anyone help me?

Much appreciated!!!

Matt

where do you get $result from ?

let i=0
for item in ${APPSARRAY[@]}
do
          #..some code to get a unique value called $result
         let i=i+1
        output="$result,$output"
done
echo $output # should have whatever you want 

Can you expand on what is required ?

i think it should be:

output="$output,$result"
printf -v output "%s," "${APPSARRAY[@]}"