如何并行运行一系列命令,并将它们的输出存储在变量中?
我试过了:
output=`(echo -n "started "; sleep 2; echo "stopped") &`
echo "output before=$output"
wait
echo "output after=$output"
停顿了两秒,接着是:
output before=started stopped
output after=started stopped
我期望:
output before=
<2 seconds pause>
output after=started stopped
如何在后台运行一系列命令,并将它们的输出存储在变量中?