Select-String in PowerShell

Example

Get the list of lines of a file that match a condition

Select-String -Pattern "Result" -Path .\README.md

README.md:32:#### Results: README.md:34:Result Load README.md:36:Result Database

You can also select the matching lines from the standard output

cat .\README.md | Select-String -Pattern "Result"

#### Results: Result Load Result Database

Context

The -Context option allows you to examine a given number of lines before/after the found match.

Get-Alias | Select-String -Pattern "tee" -Context 2

sv swmi > tee trcm type

Article author: Andrei Olegovich