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

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

问题描述

我需要将包含尖括号(< 和 >)的字符串回显到 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 命令提示符中的转义尖括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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