I would like to save the text Hello>World
in a variable in a Windows command prompt, and then echo it.
So, I run the following commands, and I am properly escaping the text by using the caret ^>
:
set i=Hello^>World
echo %i%
However, the echo
statement creates a text file called World
in the current directory, and nothing echoes to the command prompt.
How do I properly echo the variable i
without creating a file?
See screenshots:
C:\>set i=Hello^^^>World
C:\>echo %i%
Hello>World
The first caret escapes the second caret, and the third caret escapes the redirect. Then when you substitute the variable, the redirect is still escaped.