Terminal Dojo
Help العربية Sign inGet started

Command library / Select-String

Select-String

PowerShellDraft — pending expert review4 practice missions

Search text in files for a pattern

PowerShell's grep. It searches files (or piped text) for a pattern and returns each match with its file name and line number. Matching ignores case by default, and the pattern is a regular expression unless you add -SimpleMatch.

Practice Select-String

Usage

Select-String [-Pattern] <string> [-Path] <string> [-NotMatch] [-SimpleMatch] [-Context <int>]

Options and flags

Examples

Common mistakes

Select-String app.log error Select-String error app.log

Positionally the pattern comes first and the file second; swapped, it searches a file named error for the text app.log.

Related commands

get-contentget-childitemget-winevent