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 ^,

Comments (4)

  1. Wes says:

    Interesting I never knew that… you learn something new every day.

    Thanks,

    Wes

  2. Joku says:

    Same here, I thought backslash is the escape char..

  3. Weitao says:

    I know <, >, | and ^ is the escaping character, what is "&" used for in command lines?

  4. 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.