国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PowerShell > 正文

Windows Powershell條件表達式之條件操作符

2020-10-29 21:02:19
字體:
來源:轉載
供稿:網友

Powershell 中的比較運算符
-eq :等于
-ne :不等于
-gt :大于
-ge :大于等于
-lt :小于
-le :小于等于
-contains :包含
-notcontains :不包含

進行比較

可以將比較表達式直接輸入進Powershell控制臺,然后回車,會自動比較并把比較結果返回。

復制代碼 代碼如下:

PS C:Powershell> (3,4,5 ) -contains 2
False
PS C:Powershell> (3,4,5 ) -contains 5
True
PS C:Powershell> (3,4,5 ) -notcontains 6
True
PS C:Powershell> 2 -eq 10
False
PS C:Powershell> "A" -eq "a"
True
PS C:Powershell> "A" -ieq "a"
True
PS C:Powershell> "A" -ceq "a"
False
PS C:Powershell> 1gb -lt 1gb+1
True
PS C:Powershell> 1gb -lt 1gb-1
False

求反

求反運算符為-not 但是像高級語言一樣”! “ 也支持求反。

復制代碼 代碼如下:

PS C:Powershell> $a= 2 -eq 3
PS C:Powershell> $a
False
PS C:Powershell> -not $a
True
PS C:Powershell> !($a)
True

布爾運算

-and :和
-or :或
-xor :異或
-not :逆

復制代碼 代碼如下:

PS C:Powershell> $true -and $true
True
PS C:Powershell> $true -and $false
False
PS C:Powershell> $true -or $true
True
PS C:Powershell> $true -or $false
True
PS C:Powershell> $true -xor $false
True
PS C:Powershell> $true -xor $true
False
PS C:Powershell>  -not  $true
False

比較數組和集合

過濾數組中的元素

復制代碼 代碼如下:

PS C:Powershell> 1,2,3,4,3,2,1 -eq 3
3
3
PS C:Powershell> 1,2,3,4,3,2,1 -ne 3
1
2
4
2
1

驗證一個數組是否存在特定元素

復制代碼 代碼如下:

PS C:Powershell> $help=(man ls)
PS C:Powershell> 1,9,4,5 -contains 9
True
PS C:Powershell> 1,9,4,5 -contains 10
False
PS C:Powershell> 1,9,4,5 -notcontains 10
True

一、值比較

1) -eq: 相等(equal)運算符
2)

主站蜘蛛池模板: 弋阳县| 仁化县| 鱼台县| 东乡县| 扶余县| 新营市| 孟村| 武汉市| 元江| 宿松县| 泸溪县| 化州市| 德钦县| 永仁县| 广安市| 米易县| 涪陵区| 宝丰县| 新沂市| 麦盖提县| 盐源县| 本溪| 方山县| 峨眉山市| 安宁市| 肃宁县| 宜章县| 黑水县| 大石桥市| 惠州市| 宜昌市| 望江县| 东辽县| 廉江市| 漳平市| 长乐市| 闻喜县| 乐平市| 宁南县| 大理市| 独山县|