windowsbatch-fileif-statementcmd

Symbol equivalent to NEQ, LSS, GTR, etc. in Windows batch files


In batch I always use == when using the if command. (For example: if "19"=="3" echo My computer doesnt know maths)

What about for all of the others (LSS, LEQ, NEQ, etc.)? Isn't there something like != for NEQ, or am I thinking Unix?

The reason I want to use symbols is because I thought someone had said for either text or numbers symbols were more efficient than using the text variants.

Either way, I'd still like to know. Thanks.


Solution

  • The reason operators like > are not used is because they have special meanings in shell scripts. The > is used to redirect output; < used to redirect input, etc.

    The documentation from Microsoft lists the following operators:

    Operator | Description
    EQU      | equal to
    NEQ      | not equal to
    LSS      | less than
    LEQ      | less than or equal to
    GTR      | greater than
    GEQ      | greater than or equal to
    

    In addition the word not is used to negate a condition.

    The reason I want to use symbols is because I thought someone had said for either text or numbers symbols were more efficient than using the text variants.

    They were probably referring to bash and its large catalog of operators. It provides different operators for integer and string operands.