Windows命令提示符中的转义括号 [英] Escape angle brackets in a Windows command prompt

查看:469
本文介绍了Windows命令提示符中的转义括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将包含尖括号(<和>)的字符串回显到Windows计算机上的文件。基本上我想做的是:

回显一些字符串<角度>方括号>> myfile.txt

I need to echo a string containing angle brackets (< and >) to a file on a Windows machine. Basically what I want to do is the following:
echo some string < with angle > brackets >>myfile.txt

这不起作用,因为命令解释器与尖括号混淆。我可以像这样引用整个字符串:

echo某些字符串<带有尖括号>括号>> myfile.txt

This doesn't work since the command interpreter gets confused with the angle brackets. I could quote the whole string like this:
echo "some string < with angle > brackets" >>myfile.txt

但是我的文件中有不需要的双引号。

But then I have double quotes in my file that I don't want.

转义ala unix也不可行:

回显一些字符串\<角度\>方括号>> myfile.txt

Escaping the brackets ala unix doesn't work either:
echo some string \< with angle \> brackets >>myfile.txt

想法?

推荐答案

由于某些原因,Windows转义字符是^。

The Windows escape character is ^, for some reason.

echo some string ^< with angle ^> brackets >>myfile.txt

这篇关于Windows命令提示符中的转义括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆