Date: Wed, 12 Jan 2022 14:02:50 -0600 From: Ron Wills <ron@digitalcombine.ca> To: freebsd-questions@freebsd.org Subject: Piping jobs output Message-ID: <Yd8z6haDopLrG2C7@digitalcombine.ca>
next in thread | raw e-mail | index | archive | help
I have a number of shell scripts that scan various directories updating files. They can be quite time consuming so I put parts of the operations in the background and use "jobs" to manage how many things I put in the background. With bash this work beautifully but with FreeBSD's /bin/sh it's broken. So here's how I've been doing things: How I count the number of jobs I have in the background: jobs | wc -l In my scanning loop, to limit the jobs I create I have: while [ "$(jobs | wc -l)" -ge 4 ]; do sleep 2 done In /bin/sh the piping of jobs output doesn't seem to work. This lists all the jobs: jobs This always returns 0: jobs | wc -l The just returns an empty line: jobs | cat I don't know if I've stumbled on a bug or feature. I haven't seen anything that says I can't pipe the output of builtin commands in sh. This is on the lastest version FreeBSD 13. -- Ron Wills https://www.digitalcombine.ca Open Source & The Command Line
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Yd8z6haDopLrG2C7>