Where-Object

基本

 Get-ChildItem | Where-Object { $_.Extension -eq '.txt' }

省略形

 Get-ChildItem | ? { $_.Extension -eq '.txt' }

さらに省略

 dir | ? Extension -eq '.txt'

ワイルドカード

 dir | ? Name -Like '*.txt'

正規表現

 dir | ? Name -Match '\.txt$'

複数条件

OR検索

 dir -Recurse | ? { $_.Extension -eq ".jpg" -or $_.Extension -eq ".gif" }  

AND検索

 dir -Recurse | ? { $_.Extension -eq ".txt" -and $_.Length -ne 0 }  

テキストファイル内容の検索

Select-Stringを使う。

参考

http://technet.microsoft.com/ja-jp/library/dd347549.aspx


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2013-03-03 (日) 20:09:59