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:
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:
Share Improve this question edited Feb 6 at 20:59 user3163495 asked Feb 6 at 20:54 user3163495user3163495 3,5774 gold badges37 silver badges56 bronze badges1 Answer
Reset to default 2C:\>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.