#!/bin/sh # parallel variant of nargs: execute command concurrently per stdin line. # waits for the first process to finish every $core_count to limit load. core_count=$(nproc) counter=0 while read line do "$@" "$line" & if test $core_count -eq $counter then wait $pid pid=$! counter=0 else counter=$(($counter + 1)) fi done