Question

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.

Was it helpful?

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.

OTHER TIPS

More doesn't correctly parse escaped string, you need to go through some hops.

for /f "delims=" %a in ("^< test ^>") do echo %a | more
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top