OS X / Linux: pipe into two processes?

前端 未结 6 1621
醉酒成梦
醉酒成梦 2020-11-27 15:08

I know about

program1 | program2

and

program1 | tee outputfile | program2

but is there a way to feed prog

6条回答
  •  执念已碎
    2020-11-27 15:52

    Other answers introduce the concept. Here is an actual demonstration:

    $ echo "Leeroy Jenkins" | tee >(md5sum > out1) >(sha1sum > out2) > out3
    
    $ cat out1
    11e001d91e4badcff8fe22aea05a7458  -
    
    $ echo "Leeroy Jenkins" | md5sum
    11e001d91e4badcff8fe22aea05a7458  -
    
    $ cat out2
    5ed25619ce04b421fab94f57438d6502c66851c1  -
    
    $ echo "Leeroy Jenkins" | sha1sum
    5ed25619ce04b421fab94f57438d6502c66851c1  -
    
    $ cat out3
    Leeroy Jenkins
    

    Of course you can > /dev/null instead of out3.

提交回复
热议问题