jobs control in a /bin/sh script

Nikos Vassiliadis nvass at gmx.com
Sun Jul 10 15:36:26 UTC 2016


Hi,

Is there a way to redirect "jobs" output?
While this works on other bourne-like shells like zsh
or bash, it doesn't on /bin/sh.

> $ sleep 100 &
> $ sleep 100 &
> $ jobs -p
> 1760
> 1761
> $ jobs -p | cat
> $

My code looks like this:
> for j in $jobs
> do
>   (
> 	blah; blah; blah;
>   ) &
> done

and I'd like to limit the number of jobs my script could create.

Thanks,
Nikos


More information about the freebsd-questions mailing list