How do I echo a greater than sign in Cmd?

Viewed 714

How do I echo the "greater than" character in cmd? I would like to escape the "greater than" sign (>) because I need it to echo to another .bat file.

Echo net session>nul 2>&1>>2nd.bat

I need this output in 2nd.bat file:

net session>nul 2>&1

If I don't use quotes, crippled output is displayed in the prompt window.

I cannot use quotes because if I use them the output in my 2nd.bat becomes "net session>nul 2>&1" which doesn't run.

1 Answers

The answer is simple enough.

What you tried (the result of the comments):

echo net session^>nul 2^>^&1>2nd.bat

What I've tried (what works):

echo net session^>nul 2^>^&1 >2nd.bat
Related