Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run bash commands in parallel
function mycommand {
sleep 1
}
PIDS=()
for i in $(seq 1 10); do
mycommand & PIDS+=($(echo $! | sed 's/^\[[0-9]*\]//'));
done
wait ${PIDS[*]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.