PowerTip: Using PowerShell to Search Text Files for Letter Pattern

Doctor Scripto

Summary: Use Windows PowerShell to search the contents of all text files in a folder for a specific letter pattern.

Hey, Scripting Guy! Question How can I use Windows PowerShell to search the contents of a lot of files in a folder for
           the occurrence of a specific letter pattern?

Hey, Scripting Guy! Answer Use the Select-String cmdlet, and specify the pattern and the path to the files.
           Windows PowerShell automatically reads the contents of the text files, and it will show the path
           and the line number of the file that contains the pattern. Here is an example that searches
           all text files in the c:\fso folder for the pattern gps:

Select-String -Pattern "gps" -Path c:\fso\*.txt

0 comments

Discussion is closed.

Feedback usabilla icon