-eq and other comparison operators

 

🇹🇷 Karşılaştırma Operatörleri

📌 -eq (Eşit)

-eq, iki değerin eşit olup olmadığını kontrol eder. Eğer eşitse True döner, değilse False döner.

Örnek:

powershell
5 -eq 5 # True döner çünkü sayılar eşittir. 5 -eq 3 # False döner çünkü sayılar eşit değildir.

📌 -ne (Eşit Değil)

-ne, iki değerin eşit olmadığını kontrol eder. Eşit değilse True döner, eşitse False döner.

Örnek:

powershell
5 -ne 3 # True döner çünkü sayılar eşit değildir. 5 -ne 5 # False döner çünkü sayılar eşittir.

📌 -lt (Küçük)

-lt, sol operandın sağ operanddan küçük olup olmadığını kontrol eder. Eğer küçükse True döner, değilse False döner.

Örnek:

powershell
3 -lt 5 # True döner çünkü 3, 5'ten küçüktür. 7 -lt 5 # False döner çünkü 7, 5'ten küçüktür.

📌 -gt (Büyük)

-gt, sol operandın sağ operanddan büyük olup olmadığını kontrol eder. Eğer büyükse True döner, değilse False döner.

Örnek:

powershell
7 -gt 5 # True döner çünkü 7, 5'ten büyüktür. 3 -gt 5 # False döner çünkü 3, 5'ten büyüktür.

📌 -le (Küçük veya Eşit)

-le, sol operandın sağ operanddan küçük veya ona eşit olup olmadığını kontrol eder. Eğer küçük veya eşitse True döner, değilse False döner.

Örnek:

powershell
3 -le 5 # True döner çünkü 3, 5'ten küçüktür. 5 -le 5 # True döner çünkü 5, 5'e eşittir. 7 -le 5 # False döner çünkü 7, 5'ten küçük değildir.

📌 -ge (Büyük veya Eşit)

-ge, sol operandın sağ operanddan büyük veya ona eşit olup olmadığını kontrol eder. Eğer büyük veya eşitse True döner, değilse False döner.

Örnek:

powershell
7 -ge 5 # True döner çünkü 7, 5'ten büyüktür. 5 -ge 5 # True döner çünkü 5, 5'e eşittir. 3 -ge 5 # False döner çünkü 3, 5'ten büyük değildir.

📌 -like (Desene Benzer)

-like, sol operandın, sağ operandla belirtilen desene (wildcard kullanarak) uyup uymadığını kontrol eder. Yıldız (*) ve soru işareti (?) gibi joker karakterler kullanılabilir.

Örnek:

powershell
"Hello" -like "H*" # True döner çünkü "Hello", "H" ile başlar. "Hello" -like "*o" # True döner çünkü "Hello", "o" ile biter. "Hello" -like "?e*" # True döner çünkü "Hello", "e" ile başlar ve bir harf takip eder.

📌 -notlike (Desene Uymayan)

-notlike, sol operandın sağ operandla belirtilen desene uymadığını kontrol eder.

Örnek:

powershell
"Hello" -notlike "H*" # False döner çünkü "Hello", "H" ile başlar. "Hello" -notlike "*o" # False döner çünkü "Hello", "o" ile biter. "Hello" -notlike "?e*" # False döner çünkü "Hello", "e" ile başlar.

📌 -match (RegEx ile Eşleşme)

-match, sağ operandın bir regular expression (RegEx) deseni ile uyup uymadığını kontrol eder.

Örnek:

powershell
"Hello" -match "^H" # True döner çünkü "Hello" 'H' ile başlar. "Hello" -match "[A-Za-z]" # True döner çünkü "Hello" içinde harfler bulunur.

📌 -notmatch (RegEx ile Eşleşmeyen)

-notmatch, sağ operandın belirtilen RegEx deseni ile eşleşmediğini kontrol eder.

Örnek:

powershell
"Hello" -notmatch "123" # True döner çünkü "Hello" sayılarla eşleşmez. "Hello" -notmatch "^H" # False döner çünkü "Hello" 'H' ile başlar.

🇬🇧 Comparison Operators

📌 -eq (Equal)

-eq checks if two values are equal. It returns True if they are equal, otherwise False.

Example:

powershell
5 -eq 5 # True because the numbers are equal. 5 -eq 3 # False because the numbers are not equal.

📌 -ne (Not Equal)

-ne checks if two values are not equal. It returns True if they are not equal, otherwise False.

Example:

powershell
5 -ne 3 # True because the numbers are not equal. 5 -ne 5 # False because the numbers are equal.

📌 -lt (Less Than)

-lt checks if the left operand is less than the right operand. It returns True if the left operand is less, otherwise False.

Example:

powershell
3 -lt 5 # True because 3 is less than 5. 7 -lt 5 # False because 7 is not less than 5.

📌 -gt (Greater Than)

-gt checks if the left operand is greater than the right operand. It returns True if the left operand is greater, otherwise False.

Example:

powershell
7 -gt 5 # True because 7 is greater than 5. 3 -gt 5 # False because 3 is not greater than 5.

📌 -le (Less Than or Equal)

-le checks if the left operand is less than or equal to the right operand. It returns True if the left operand is less than or equal, otherwise False.

Example:

powershell
3 -le 5 # True because 3 is less than 5. 5 -le 5 # True because 5 is equal to 5. 7 -le 5 # False because 7 is not less than or equal to 5.

📌 -ge (Greater Than or Equal)

-ge checks if the left operand is greater than or equal to the right operand. It returns True if the left operand is greater or equal, otherwise False.

Example:

powershell
7 -ge 5 # True because 7 is greater than 5. 5 -ge 5 # True because 5 is equal to 5. 3 -ge 5 # False because 3 is not greater than or equal to 5.

📌 -like (Wildcard Match)

-like checks if the left operand matches the pattern (using wildcards like * and ?).

Example:

powershell
"Hello" -like "H*" # True because "Hello" starts with "H". "Hello" -like "*o" # True because "Hello" ends with "o". "Hello" -like "?e*" # True because "Hello" starts with "e" after the first letter.

📌 -notlike (Not Wildcard Match)

-notlike checks if the left operand does not match the pattern.

Example:

powershell
"Hello" -notlike "H*" # False because "Hello" starts with "H". "Hello" -notlike "*o" # False because "Hello" ends with "o". "Hello" -notlike "?e*" # False because "Hello" starts with "e".

📌 -match (Regex Match)

-match checks if the left operand matches the provided regular expression (regex).

Example:

powershell
"Hello" -match "^H" # True because "Hello" starts with "H". "Hello" -match "[A-Za-z]" # True because "Hello" contains letters.

📌 -notmatch (Regex Not Match)

-notmatch checks if the left operand does not match the regular expression.

Example:

powershell
"Hello" -notmatch "123" # True because "Hello" doesn't contain digits. "Hello" -notmatch "^H" # False because "Hello" starts with "H".