I need to run two commands in parallel and get the output from both in the same shell.
Edit:
I am trying to run multiple long-running commands that watch the file system and compile various things for me (CoffeeScript, Jade, sass).
command1 &
command2 &
それらは両方とも並行して実行されています。それらの出力は画面に表示されます。
あなたはおそらくbashのwaitコマンドを見ています。次のスクリプトを検討してください。
#!/bin/bash
FAIL=0
echo "starting"
./script1 &
./script2 &
for job in `jobs -p`
do
echo $job
wait $job || let "FAIL+=1"
done
echo $FAIL
if [ "$FAIL" == "0" ];
then
echo "All jobs completed!"
else
echo "Jobs FAILED: ($FAIL)"
fi