Created
February 24, 2016 01:55
-
-
Save stretchkennedy/6afe9a9b2834c892c9b6 to your computer and use it in GitHub Desktop.
Run bash commands in parallel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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