#!/bin/bash
update() {
local i="$1"
echo "./update.sh $i"
}
loop_func() {
local d;
for d in {2..40}; do
update $d 1>&2 &
echo $!
done
}
pids=( $(loop_func) )
wait ${pids[@]} &>/dev/null
echo "d: $d"
IyEvYmluL2Jhc2gKCnVwZGF0ZSgpIHsKICAgIGxvY2FsIGk9IiQxIgoKICAgIGVjaG8gIi4vdXBkYXRlLnNoICRpIgp9Cgpsb29wX2Z1bmMoKSB7CiAgICBsb2NhbCBkOwoKICAgIGZvciBkIGluIHsyLi40MH07IGRvCiAgICAgICAgdXBkYXRlICRkICAxPiYyICYKICAgICAgICBlY2hvICQhCiAgICBkb25lCn0KCnBpZHM9KCAkKGxvb3BfZnVuYykgKQp3YWl0ICR7cGlkc1tAXX0gJj4vZGV2L251bGwKZWNobyAiZDogJGQi