Last active
April 30, 2024 07:43
-
-
Save bokwoon95/5cf4696dd1bed23aa3bda591fd24849b to your computer and use it in GitHub Desktop.
How to pass multiple arguments to arbitrary commands to run in parallel with xargs
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
#!/bin/sh | |
echo 'linux amd64 "Intel Linux" | |
linux arm64 "ARM Linux" | |
darwin amd64 "Intel macOS" | |
darwin arm64 "Apple Silicon macOS" | |
windows amd64 "Intel Windows"' | tr '\n' '\0' | xargs -0 -I{} -P4 sh -c 'f() { | |
echo "os=$1 arch=$2 desc=$3"; | |
}; f {}' |
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
os=linux arch=amd64 desc=Intel Linux | |
os=linux arch=arm64 desc=ARM Linux | |
os=darwin arch=amd64 desc=Intel macOS | |
os=darwin arch=arm64 desc=Apple Silicon macOS | |
os=windows arch=amd64 desc=Intel Windows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment