Skip to content

Instantly share code, notes, and snippets.

@yrgoldteeth
Created August 7, 2013 18:38
Show Gist options
  • Save yrgoldteeth/6177085 to your computer and use it in GitHub Desktop.
Save yrgoldteeth/6177085 to your computer and use it in GitHub Desktop.
#!/bin/bash
# From http://stackoverflow.com/questions/10909685/run-parallel-multiple-commands-at-once-in-the-same-terminal
# Usage: parallel_commands "cmd arg0 arg1 arg2" "other_cmd arg0 arg2 arg3"
for cmd in "$@"; do {
echo "Process \"$cmd\" started";
$cmd & pid=$!
PID_LIST+=" $pid";
} done
trap "kill $PID_LIST" SIGINT
echo "Parallel processes have started";
wait $PID_LIST
echo
echo "All processes have completed";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment