This is what I tested in Arch's dash shell and FreeBSD's default sh shell, the results are the same.
$ sleep 100 &
$ jobs
[1] + Running sleep 100
$ jobs | wc
0 0 0
$ jobs | grep 1
I can't wc or grep on the output of jobs command. The jobs command is shell built-in.
What is the reason for this? is it that jobs somehow prints different information in interactive shell and to pipe? I don't know details about that, but I knew about similar behavior of ls. I.e., you will see compact output of ls in shell, but grep will treat each file name in a standalone line instead.
Edit: I found a similar question: How to kill all background jobs in dash?, that question is also due to not being able to get the output of jobs command.
jobsactually write? – Panki Oct 08 '21 at 11:00jobs 2>&1 | wc, then it's not working either. Actually, if thejobsoutput was to stderr, it should be shown together withwc/grepoutput, instead of disappear. – Lu Xu Oct 08 '21 at 12:08