Skip to content

Instantly share code, notes, and snippets.

@smerrill
Created September 2, 2011 10:05
Show Gist options
  • Save smerrill/1188307 to your computer and use it in GitHub Desktop.
Save smerrill/1188307 to your computer and use it in GitHub Desktop.
Run a list of commands (one per line) with a certain concurrency.
cat big_list_of_commands.txt | tr '\n' '\0' | xargs -0 -n1 -P{thread-count} bash -c
# or, per the example given:
(for i in 1 2 3 4 5 6 7 8 9 10; do echo "echo 'Delay $i'; sleep $i ; echo 'Done $i'" ; done) | tr '\n' '\0' | xargs -0 -n1 -P4 bash -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment