问题描述
我需要将包含尖括号(< 和 >)的字符串回显到 Windows 机器上的文件中.基本上我想做的是以下内容:echo some string <带角度 >方括号 >>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 "some string < with angle >括号" >>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 命令提示符中的转义尖括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!