'How do I echo a greater than sign in Cmd?

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.



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Choni01