Search code examples
batch-filesyntaxcmdoperators

Batch: what is the pipe | used for?


Hello stackoverflow users!

I'm not really new to batch. I just never used pipes | in batch and even after I read reference on ss64.com I don't understand what's the pipe used for.

At first I thought it is OR operator or something (obviously I know now it's not).

I only know that it's located between two lines (commands) like &, but I still don't get what it does exactly, and how it is used practically in code.

Thanks for answering!


Solution

  • Pipe [|]: Redirect standard output of commandA to standard input of commandB

    http://www.robvanderwoude.com/redirection.php

    example :

    echo KKZiomek | find "KKZ"
    

    will redirect the echo KKZiomek in the input of the FIND and be used as second parameter of it.

    Like well commented by @aschipfl the space is piped too. so better use :

    echo KKZiomek| find "KKZ"