I want to run a sequence of command pipelines with pv
on each one. Here's an example:
for p in 1 2 3
do
cat /dev/zero | pv -N $p | dd of=/dev/null &
done
The actual commands in the pipe don't matter (cat
/dd
are just an example)…
The goal being 4 concurrently running pipelines, each with their own pv
output. However when I try to background the commands like this, pv
stops and all I get are 4 stopped jobs. I've tried with {...|pv|...}&
, bash -c "...|pv|..." &
all with the same result.
How can I run multiple pv
command pipelines concurrently?
Best Answer
Found that I can do this with
xargs
and the-P
option:Send output of the array to iterate over into stdin of
xargs
; To run all commands simultaneously, use-P 0