#!/bin/bash
test () {
     echo $a
     sleep 2
}

for a in $(seq 10);do
     test &
     ((num++))
     if [[ $num -eq 6 ]];then
        wait
        num=0
     fi
done
wait