0

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.

Kriem
  • 8,666
  • 16
  • 72
  • 120
N00b101
  • 165
  • 7

2 Answers2

1

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

for /f "delims=" %a in ("^< test ^>") do echo %a | more
Luiz Felipe
  • 1,123
  • 8
  • 14
  • That is a fine solution, but the explanation is incorrect. MORE has no problem processing `<` and `>` characters. See [my answer](http://stackoverflow.com/a/22673717/1012053) for a more accurate explanation. – dbenham Mar 26 '14 at 21:47
1

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.

Community
  • 1
  • 1
dbenham
  • 127,446
  • 28
  • 251
  • 390