Search code examples
windowscmdpiping

Windows piping simple issue


I want to do this:

echo < test > | more

This didn't work, so I tried this:

echo ^< test ^> | more

This didn't work either

What am I doing wrong?

PS.: I need the brackets to be printed. They part of the string I need.


Solution

  • Because of how pipes are implemented by Windows CMD.EXE, the ECHO statement gets parsed twice, so the special characters must be escaped twice.

    echo ^^^< test ^^^> | more
    

    See Why does delayed expansion fail when inside a piped block of code? and all the answers for an in depth discussion of the many non-intuitive features of pipes.