Why Batch file inserting 0?

Processing of Batch file, I have created simple batch file for processing some :

abc<def
abc <def
abc def<def

When I run the command from cmd the output is as under:

abc<def        =>  abc0<def
abc <def       =>  abc  0<def
abc def<def    =>  abc def 0<def

I don't know why "0" is added before "<" and how to get rid of it.

1 answer

  • answered 2020-06-02 11:17 Vineet1982

    Escape Character

    ^ Escape character.

    You can prevent the special characters that control command syntax from having their special meanings as follows, except for the percent sign (%):

    • You can surround a string containing a special character by quotation marks.
    • You can place caret (^), an escape character, immediately before the special characters. In a command located after a pipe (|), you need to use three carets (^^^) for this to work.

    The special characters that need quoting or escaping are usually <, >, |, &, and ^. In some circumstances, ! and \ may need to be escaped.

    Adding the escape character before a command symbol allows it to be treated as ordinary text.

    When piping or redirecting any of these characters you should prefix with the escape character: & \ < > ^ |

    Example:

     ^\  ^&  ^|  ^>  ^<  ^^ 
    

    So when Running

    Current Text    =>    Replace With
    abc<def         =>    abc^<def
    abc <def        =>    abc ^<def
    abc def<def     =>    abc def<def
    

    When I run the command from cmd the output is as under:

    abc<def
    abc <def
    abc def<def