Example of using named pipes in Linux Bash

前端 未结 4 538
一向
一向 2020-12-02 05:36

Can someone post a simple example of using named pipes in Bash in Linux?

4条回答
  •  Happy的楠姐
    2020-12-02 06:38

    Here are the commands:

    $ mkfifo named_pipe
    
    $ echo "Hi" > named_pipe &
    
    $ cat named_pipe
    

    The first command creates the pipe.

    The second command writes to the pipe (blocking). The & puts this into the background so you can continue to type commands in the same shell. It will exit when the FIFO is emptied by the next command.

    The last command reads from the pipe.

提交回复
热议问题