N00b101
N00b101

Reputation: 165

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.

Upvotes: 0

Views: 47

Answers (2)

dbenham
dbenham

Reputation: 130919

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.

Upvotes: 1

Luiz Felipe
Luiz Felipe

Reputation: 1189

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

for /f "delims=" %a in ("^< test ^>") do echo %a | more

Upvotes: 1

Related Questions