Grep files with Powershell

Powershell can be used to search for content (with regex support) for files in a path by using Select-String:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Select-String -Path "E:\Text_Files\*" -Pattern "^My string to search for$"
Select-String -Path "E:\Text_Files\*" -Pattern "^My string to search for$"
Select-String -Path "E:\Text_Files\*" -Pattern "^My string to search for$"

The output of the command looks like this for any results:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
testfile.txt:1:My string to search for
testfile.txt:1:My string to search for
testfile.txt:1:My string to search for

Leave a Reply

Your email address will not be published. Required fields are marked *