Created
May 8, 2017 06:44
-
-
Save Matticusau/4d5487053c9be21f7b8aecae8cf8a2e0 to your computer and use it in GitHub Desktop.
Find files with contents matching a RegEx pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$searchPath = (Get-Location).Path; | |
$searchRegEx = 'find this text' | |
Get-ChildItem -Path $searchPath -Recurse -File | % {if ((Get-Content -Path $PSItem.FullName | Out-String) -match $searchRegEx) {Write-Host $PsItem.FullName -ForegroundColor Red} else {Write-Host $PsItem.FullName -ForegroundColor green}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment