count=0 for pid in $(jobs -p); do wait $pid [ "x$?" == "x0" ] && ((count++)) done echo $count" processes done"