> Anyway, those three are just off the top of my head, unfairness-wise. Last I looked at the source for GNU parallel it looked like mountains upon mountains of Perl I would rather not depend upon, personally, but to each his own.
Well, there was a Rust version with zero Perl, now unfortunately archived. It wasn't 100% on a par with the original and wasn't really finished. On the other hand, built easily for Windows and helped me on a few occasions.
Well, some archived project is not so great either. The core functionality is not even a 20 line bash script since bash grew wait -n, though:
#!/bin/bash
if [ "${1-0}" -lt 1 ]; then # No arg / arg not a number >= 1
echo "Usage: $0 <N>"; echo "reads cmds from stdin, running up to N at once."
exit 1
fi
TMP=`mktemp -t stripen.XXXXXX`
trap 'rm -f $TMP; exit 0' HUP INT TERM EXIT
STRIPE_SEQ=1
while read cmd; do
jobs > $TMP # jobs | wc -l does not work
if [ $(wc -l < $TMP) -ge $1 ]; then
wait -n # Wait for 1/more jobs to finish
fi # Could accumulate total $? above, but would need to replace final wait.
STRIPE_SEQ=$((STRIPE_SEQ + 1))
( eval "$cmd" ) < /dev/null & # Run job in a subshell in bg
done
rm -f $TMP
wait # Wait for all to finish
and if bash ever grows some magic environment variable $NUM_BG_JOBS or you don't want auto-help or sequence numbers or etc. it can be even simpler.
sure a "parallel xargs" can ostensibly be implemented in POSIX sh but that's merely the tip of the iceberg with what parallel can do. why not just skim the documentation and give it a try?
Well, there was a Rust version with zero Perl, now unfortunately archived. It wasn't 100% on a par with the original and wasn't really finished. On the other hand, built easily for Windows and helped me on a few occasions.
https://github.com/mmstick/parallel