Batch-script-relational-operators

提供:Dev Guides
移動先:案内検索

バッチスクリプト-関係演算子

関係演算子は、オブジェクトの比較を許可します。 以下は利用可能な関係演算子です。

次のコードスニペットは、さまざまな演算子の使用方法を示しています。

@echo off
SET/A a = 5
SET/A b = 10
if %a% EQU %b% echo A is equal to than B
if %a% NEQ %b% echo A is not equal to than B
if %a% LSS %b% echo A is less than B
if %a% LEQ %b% echo A is less than or equal B
if %a% GTR %b% echo A is greater than B
if %a% GEQ %b% echo A is greater than or equal to B

出力

上記のコマンドは、次の出力を生成します。

A is not equal to than B
A is less than B
A is less than or equal B