Created
March 21, 2020 15:06
-
-
Save isopropylcyanide/10b9ba1548e5129b62b9e9395f3406c6 to your computer and use it in GitHub Desktop.
Generic function that utilises function arguments to fire commands for a total of `N` times in `M` jobs at a 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
# Generic function that utilises function arguments to fire commands for a total of `N` times in `M` jobs at a parallel | |
set -o xtrace | |
function conc(){ | |
cmd=("${@:3}") | |
seq 1 "$1" | xargs -n1 -P"$2" "${cmd[@]}" | |
} | |
# $ conc N M cmd | |
# $ conc 10 2 curl --location --request GET 'http://google.com/' | |
# This will fire `10` curl commands at a max parallelism of two each. | |
# Adding this function to the `bash_profile` makes it easier. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment