Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
143 views
in Technique[技术] by (71.8m points)

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.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...