Escape angle brackets in a Windows command prompt

Jason picture Jason · Oct 30, 2008 · Viewed 44.1k times · Source

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

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.

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

Ideas?

Answer

Tim Robinson picture Tim Robinson · Oct 30, 2008

The Windows escape character is ^, for some reason.

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