Select-String
Find text in strings and files in PowerShell. You can use
Select-Stringsimilar togrepin UNIX orfindstr.exein Windows. Note: This command can only be used through PowerShell. More information: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/select-string.
- Search for a pattern within a file:
Select-String -Path "" -Pattern ''
- Search for an exact string (disables
regex):
Select-String -SimpleMatch ""
- Search for pattern in all
.extfiles in current dir:
Select-String -Path "" -Pattern ''
- Capture the specified number of lines before and after the line that matches the pattern:
Select-String --Context ""
- Search
stdinfor lines that do not match a pattern:
Get-Content | Select-String --NotMatch ""
来源:tldr-pages contributors · 作者与贡献记录 · CC BY 4.0。离线整理了版式、链接和媒体显示。
