Select-String

noun

say it: “suh-LEKT STRING” /səˈlɛkt ˈstrɪŋ/

A PowerShell command that searches the text inside files for a word or pattern and shows each matching line.

What does Select-String do?

Select-String searches the text inside files, or text sent down the pipeline, for a word or a regular expression. Each match is an object with properties such as Filename, LineNumber and Line, and -List stops at each file's first match. It ignores capitals unless you add -CaseSensitive.

Select-String reading-room logs\* | Select-Object Filename, LineNumber

In a sentence

  • “Select-String reading-room logs\* found every log line that mentioned the reading room.”
  • “Each result from Select-String knows its file name, line number and line.”

Level: Apprentice · More PowerShell terms at this level

Updated