Powershell 条件操作符
2016-08-22 17:50
239 查看
Powershell 中的比较运算符
-eq :等于
-ne :不等于
-gt :大于
-ge :大于等于
-lt :小于
-le :小于等于
-contains :包含
-notcontains :不包含
-or :或
-xor :异或
-not :逆
验证一个数组是否存在特定元素
-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
相关文章推荐
- Powershell 条件操作符
- MongoDB 条件操作符
- SQL 语句中 IN 操作符 , as 语法 和 BETWEEN AND 条件语句
- MongoDB $type 操作符和 条件操作符
- PowerShell-条件表达式
- PowerShell使用match操作符来筛选数组
- 实验4-7 条件操作符
- RxJava----操作符:条件和布尔操作符
- python3.4学习笔记(十) 常用操作符,条件分支和循环实例
- MongoDB 条件操作符
- MongoDB 高级查询条件操作符
- PowerShell 字符串操作符
- C++ 唯一三元操作符: 条件操作符?
- java 条件表达式(即三元操作符)的陷阱
- 逻辑、条件、逗号表达式操作符
- ISO/IEC 9899:2011 条款6.5.15——条件操作符
- 条件操作符和sizeof操作符
- AxureRP7.0教程 AxureRP7.0条件操作符详解 条件操作符 Conditional Operator
- C++primer5.5-5.7 自增自减、箭头、条件操作符
- mongodb笔记03(MongoDB 条件操作符)