String Search in Directory of TXT Files using Powershell

If you work with ASCII text files a lot, you may find the need to search for a string within any of those text files at the directory level instead of each individual file. Here’s how to do that:

  • Select-String -Path c:\fso\*.txt, c:\fso\*.log -pattern modified,lastmod

This will search anything .txt or .log within c:\fso for the string “modified” or “lastmod” and include all results together in a list sent to the console.

Leave a Reply

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