Is there a way to deploy a stream to posix shell or bash?

I would like something that works:

cat a > b
prog1 < b
prog2 < b

without creating a temporary file b.

If I had only one program, I could use the channel:

cat a | prog1

I am wondering if the shell supports syntax for supporting something like:

cat a (|prog1) (|prog2)

Or is there a handy utility that can help? Sort of:

cat a | fanout prog1 prog2
+4
source share
1 answer

You can use tee + process substitution fork the data stream and send it to several processes.

cat a | tee >(prog1) | prog2

tee . >(prog1) , /dev/fd/63, tee .

, :

cat a | tee >(prog1) >(prog2) >(prog3) | prog4
+6

Source: https://habr.com/ru/post/1676855/


All Articles