Skip to main content

Grundlagen - Operatoren

########################################

# Operatoren
#  Vergleichsoperatoren, stringoperatoren

# Mathematische Operatoren
# +, -, *, :, ^
#
# Zuweisungsoperatoren
# =, +=, -=, *=, ^

# logische Operatoren
# and, or , not

# unnäre Operatoren
# i++


Clear-host

"Apfel" -eq "Birne"
"Apfel" -ceq "apfel"    ####-ceq steht für case sensitive

12 -eq 12 #true  gleich  (equal)
12 -ne 15 #true ungleich (not equal)
12 -gt 9  #true größer als (greater than)
12 -lt 9  #true kleiner als (less than)
12 -ge 11 #true größer gleich (greater equal)
12 -le 12  #true kleiner gleich (less equal)

"Apfel" -lt "Birne"  #alphabetisch

#like

"Apfel" -like "a*"
"Apfel" -like "Apf*"
"Apfel" -like "Apfel*" # * beliebig viele Zeichen, ein zeichen oder kein zweichen
"Apfel" -like "?fel" # ? genau ein Zeichen
"Apfel" -like "?????" # 

# Match, Substrings (teilzeichenketten)

"Apfel" -match "apf" #true
"Apfel" -cmatch "apf" #False
"tapfer" -match "apf"  #true

"apfel" -notmatch "pfel"  #True
"Apfel" -cnotmatch "apfel"  #True

# Contains, Werte in Liste
"Apfel", "Opfel", "Ipfel" -contains "pfel" #false
"Apfel", "Opfel", "Ipfel" -contains "apfel" #True
"Apfel", "Opfel", "Ipfel" -ccontains "apfel" #false
"Apfel", "Opfel", "Ipfel" -notcontains "pfel" #True

# in, werte in Liste (auf der rechten Seite)
"Apfel" -in "Opfel", "Apfel", "ipfel" #true
"Apfel" -notin "Opfel", "Apfel", "ipfel" #false
"Apfel" -iin "Opfel", "Ipfel", "ipfel" # i => case insensitive

###########################################################################################################

# logische Operatoren