Page 1 of 1

Write symbol ">"

Posted: 16 Jan 2011 02:19
by walter4991
Hello guys, I have something to ask:
how do I write the symbol ">" in a batch file, for example:

Code: Select all

tree echo>nul>>test.bat


The command in the file bat write only

Code: Select all

tree
, then how do I write ">nul" ???
Thank's...

Re: Write symbol ">"

Posted: 16 Jan 2011 04:14
by amel27
by "^" symbol before ">"

Code: Select all

echo tree ^>nul>>test.bat

Re: Write symbol ">"

Posted: 16 Jan 2011 04:41
by walter4991
thanks a lot, it works ... but what does it mean "^" ???

Re: Write symbol ">"

Posted: 16 Jan 2011 06:10
by amel27
Escape special characters,
read this: http://www.dostips.com/?t=Snippets.Escape

Re: Write symbol ">"

Posted: 16 Jan 2011 06:46
by walter4991
Thank you very very much... :D

Re: Write symbol ">"

Posted: 16 Jan 2011 12:16
by jeb
At the page are missing some more cases.

Code: Select all

SETLOCAL DISABLEDELAYEDEXPANSION
echo 1 ^^^^ "^^^^"
echo 2 ^^^^ "^^^^" ^^!

echo *******
SETLOCAL ENABLEDELAYEDEXPANSION
echo 3 ^^^^ "^^^^"
echo 4 ^^^^ "^^^^" ^^!

---- OUTPUT ----

1 ^^ "^^^^"
2 ^^ "^^^^" ^!
*******
3 ^^ "^^^^"
4 ^ "^^" !


As you can see, number 4 seems to be really mysterious.
To understand the escape mechanism is one of the major keys of batch files.

hope it helps
jeb