Search code examples
linuxpipepiping

Linux piping & loop


Is it possible to create a loop using Linux pipes? E.g.

cmd1 | cmd2 | cmd3 | 'back to stdin cmd1'

In other words, I'd like stdout at cmd3 to be connected back to stdin of cmd1.


Solution

  • You could use a named pipe/FIFO:

    mkfifo cmd3-to-cmd1
    cmd1 < cmd3-to-cmd1 | cmd2 | cmd3 >> cmd3-to-cmd1