Welcome to MSDN Blogs Sign in | Join | Help

echo '>' and '<'

'>' and '<' are special characters in command prompt. They means input and output redirect. So they can't be directly echoed in command prompt. You need to escape them with '^'.

C:\>echo <
The syntax of the command is incorrect.

C:\>echo ^<
<

This is mentioned in http://www.microsoft.com/windowsxp/home/using/productdoc/en/default.asp?url=/windowsxp/home/using/productdoc/en/ntcmds_shelloverview.asp

The following characters are special and have to be escaped:
<, >, |, &, or ^,

Published Friday, May 14, 2004 1:24 PM by junfeng
Filed under:

Comments

# re: echo '>' and '<'

Friday, May 14, 2004 3:41 PM by Wes
Interesting I never knew that... you learn something new every day.

Thanks,
Wes

# re: echo '>' and '<'

Saturday, May 15, 2004 3:55 AM by Joku
Same here, I thought backslash is the escape char..

# re: echo '>' and '<'

Tuesday, July 20, 2004 10:58 AM by Weitao
I know <, >, | and ^ is the escaping character, what is "&" used for in command lines?

# re: echo '>' and '<'

Tuesday, July 20, 2004 11:01 AM by Junfeng Zhang
Copy from the URL provided above

Character Syntax Definition
& [...] command1 & command2 Use to separate multiple commands on one command line. Cmd.exe runs the first command, and then the second command.
&& [...] command1 && command2 Use to run the command following && only if the command preceding the symbol is successful. Cmd.exe runs the first command, and then runs the second command only if the first command completed successfully.
|| [...] command1 || command2 Use to run the command following || only if the command preceding || fails. Cmd.exe runs the first command, and then runs the second command only if the first command did not complete successfully (receives an error code greater than zero).
( ) [...] (command1 & command2) Use to group or nest multiple commands.
; or , command1 parameter1;parameter2 Use to separate command parameters.
New Comments to this post are disabled
 
Page view tracker