Consider the following contrived command:
cat /dev/urandom | wc -c
If you run it, cat
sits and spins forever. If the process is killed with ^C
, the whole pipeline will stop and wc
will never show its count. In most cases, this is the desired and appropriate behavior.
Suppose I wanted to stop cat
and still run wc
-- in essence, count the number of characters that went through up until the process was killed. Is there a nice way to accomplish that without switching to another shell and running kill <PID of cat>
?