On Thu, 27 Nov 2008 15:24, Ron Isaacson wrote:
>
>   #!/bin/ksh
>
>   while read task; do
>     $task &
>     while [[ `jobs | wc -l` -ge 3 ]]; do sleep 1; done
>   done
>
>   while [[ `jobs | wc -l` -gt 0 ]]; do sleep 1; done
>

hmmm, or something along the lines of

    let n=0
    let lim=3
    while read task; do
        $task &
        if [[ $((++n)) -ge $lim ]]; then
            wait
            let n--
        fi
    done

    while [[ $((n--)) -gt 0 ]]; do
        wait
    done

only because I dislike using sleep in any task just to avoid counting or 
waiting properly. Have I got my pre-fix and post-fix operators on the right 
side both times?


_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to