tags:

views:

1656

answers:

2

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?

+21  A: 

The Windows escape character is ^, for some reason.

echo some string ^< with angle ^> brackets >>myfile.txt
Tim Robinson
Well, backslash is used for pathnames and double-quote is to wrap filename which have spaces, so there not many character choices left.
James Curran
A: 

Escaping the brackets ala unix doesn't work either:

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

The backslash would be considered the start of a absolute pathname.

James Curran
Absolute pathname relative to the current drive letter... ;)
dalle