Skip to content

Instantly share code, notes, and snippets.

@mpapi
Created September 25, 2011 02:47
Show Gist options
  • Save mpapi/1240155 to your computer and use it in GitHub Desktop.
Save mpapi/1240155 to your computer and use it in GitHub Desktop.
A quick shell script to run commands in parallel batches
#!/bin/bash
COMMAND=$1
PARALLEL=${2:-2}
while read cmd
do
echo "'$(echo $COMMAND | sed "s/{}/$cmd/g")'"
done | xargs -n1 -P$PARALLEL sh -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment