最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Echoing a variable with a greater than sign (>) in a Windows command prompt causes a file creation, even after using the

programmeradmin3浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 2
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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论