Skip to content

Instantly share code, notes, and snippets.

@stretchkennedy
Created February 24, 2016 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stretchkennedy/6afe9a9b2834c892c9b6 to your computer and use it in GitHub Desktop.
Save stretchkennedy/6afe9a9b2834c892c9b6 to your computer and use it in GitHub Desktop.
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