Bash run two commands and get output from both

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

Edit:

I am trying to run several long commands that look at the file system and compile different things for me (coffeescript, jade, sass).

-3
source share
2 answers

You'll probably see the 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 

Provided by

0
source
 command1 & command2 & 

They both work in parallel; their output goes to the screen.

0
source

All Articles