Here's an example program:
#!/bin/bash
for x in {1..5}
do
output[$x]=$(echo $x) &
done
wait
for x in {1..5}
do
echo ${output[$x]}
done
I would expect this to run and print out the values assigned to each member of the output
array, but it prints nothing. Removing the &
correctly assigns the variables. Must I use different syntax to achieve this in parallel?