I have tried to write a shell script which logins in multiple hosts via ssh, execute some commands, and print execution summary. So far, I have written a script which works in sequential way. But it's slow, I want to rewrite it in a parallel way. I know I can use & to run multiple ssh commands parallel, and use command substitution to store subshell output into variable. But I cannot combine them correctly.So far, I came out these code. But it still runs in sequential way.#!/bin/bashhosts=('host-1' 'host-2' 'host-3')cmd='sleep $[ (( $RANDOM % 20 ) + 1) /10 ]s && echo hello world'i=0for host in ${hosts[@]}; do    var1=$(ssh $host $cmd &)    echo i = $i    outputs[i]=$var1    ((i++))doneecho 'wait'waitecho ${outputs[@]
How to run multiple ssh commands parallel and store outputs into variables
shell