Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Using PowerShell to Search Text Files for Letter Pattern

$
0
0

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


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>