搜尋檔案內容(PowerShell)
- UtilsPowerShell搜尋Select-StringWindows作者:VincentCorgi約 1 分鐘閱讀
功能
示範用 PowerShell 在目錄樹中 依檔案內容字串搜尋(Select-String 管線)等寫法。
情境
- 在 Windows 上沒有 IDE 全文搜尋、或要在大量 log/設定檔裡找關鍵字時,於適當路徑下執行以下指令。
用字串找檔案
Code
Get-ChildItem -Recurse -File |
Select-String "<search_string>"
限定檔案類型
Code
Get-ChildItem -Recurse -File -Filter *.html |
Select-String "<search_string>"