「PowerShell」while文を使うサンプル
書式
while (条件式)
{
処理コード
}
条件がtrueの間、処理を繰り返します。
条件式がfalseの場合、処理を終了します。
使用例
$i = 10
while ($i -lt 15) {
Write-Host($i)
$i = $i + 1
}
$i = 10
while ($i -lt 15) {
Write-Host($i)
$i = $i + 1
}
$i = 10 while ($i -lt 15) { Write-Host($i) $i = $i + 1 }
実行結果
PS C:\study\powershell> ./test.ps1
10
11
12
13
14
PS C:\study\powershell> ./test.ps1
10
11
12
13
14
PS C:\study\powershell> ./test.ps1 10 11 12 13 14