欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Windows Powershell Foreach 循環(huán)

 更新時(shí)間:2014年10月02日 12:08:28   投稿:hebedich  
Foreach-object 為cmdlet命令,使用在管道中,對(duì)管道結(jié)果逐個(gè)處理,foreach為遍歷集合的關(guān)鍵字。

下面舉兩個(gè)例子:

復(fù)制代碼 代碼如下:

$array=7..10
foreach ($n in $array)
{
    $n*$n
}
 
#49
#64
#81
#100
 
foreach($file in dir c:\windows)
{
    if($file.Length -gt 1mb)
    {
        $File.Name
    }
}
 
#explorer.exe
#WindowsUpdate.log

這里只為了演示foreach,其實(shí)上面的第二個(gè)例子可以用Foreach-Object更簡(jiǎn)潔。

復(fù)制代碼 代碼如下:

PS C:\Powershell> dir C:\Windows | where {$_.length -gt 1mb} |foreach-object {$_.Name}
explorer.exe
WindowsUpdate.log

相關(guān)文章

最新評(píng)論