Search code examples
linuxbashshellpipezsh

How to use a pipe if a command specifies a file for output


I have command line utility that accepts a file for its output. I want to pipe this output for further processing.

I first tried this:

command - | anothercommand

But it did not work, it interpreted the - literally. (So it created a file called -)

This did work:

command >(anothercommand)

Which is fine, but I wonder if it still can be done with a pipe.

I thought of

command >(tee) | anothercommand

But that only send the output to stdout.


Solution

  • You can use /dev/stdout as your output file:

    command /dev/stdout | anothercommand