本文介绍了击运行两个命令,并从都得到输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要并行运行的两个命令和从两者在相同的外壳得到的输出

I need to run two command in parallel and get the output from both in the same shell.

编辑:

我试图运行监控文件系统中的多个长期运行的命令和编制各种事情,我(的CoffeeScript,玉器,SASS)。

I am trying to run multiple long-running commands that watch the file system and compile various things for me(coffeescript, jade, sass).

推荐答案

你可能在bash看着等待命令。考虑一下这个脚本:

You're probably looking at wait command in bash. Consider this script:

#!/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

这篇关于击运行两个命令,并从都得到输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 00:03
查看更多