I know this isn't necessarily the best way to do things, but I'm in the process of learning Bash scripting and I'm trying to implement some sort of concurrency. Is it possible to send tasks to the background and then have them update a record (an array, perhaps) in the main script when they're done?
Here's an example of what I've tried and failed with so far:
Code:
arr=({0..9})
for i in ${!arr[*]}
do
jobs=0
while [[ $jobs -lt 2 ]]
do
$arr[$i]=$(ping -c 1 localhost &)
let "jobs++"
done
wait
done
Would it make any difference in terms of "backgroundability" if the task involved piping?