In [2]:
# is null or empty
[string]::IsNullOrEmpty("")
[string]::IsNullOrEmpty($null)
In [4]:
# "${base%/}/${rel}"
Write-Output (Join-Path "~/" ".zshrc")
In [25]:
# dirname (readlink -f /Users/pogin/.bashrc)
Write-Output (Split-Path -Parent "/Users/pogin/.bashrc")
In [2]:
$x = 0
while ($x -lt 5) {
$x += 1
Write-Output $x
}
In [3]:
$items = 1..10
foreach ($item in $items) {
write-output $item
}
In [5]:
# switch
$i = 3
switch ($i) {
1 {Write-Output "1"; break}
2 {Write-Output "2"; break}
{$_ -lt 5} {Write-Output "5より小さい"; break}
default {Write-Output "default句"; break}
}
In [7]:
$num1 = 1
$num2 = 2
$num1 -eq $num2 # == $num1は$num2と等しい
$num1 -ne $num2 # != $num1は$num2は等しくない
$num1 -lt $num2 # < $num1は$num2より小さい
$num1 -gt $num2 # > $num1は$num2より大きい
$num1 -le $num2 # <= $num1は$num2以下
$num1 -ge $num2 # >= $num1は$num2以上
In [ ]: