Skip to content

Instantly share code, notes, and snippets.

@Matticusau
Created May 8, 2017 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Matticusau/4d5487053c9be21f7b8aecae8cf8a2e0 to your computer and use it in GitHub Desktop.
Save Matticusau/4d5487053c9be21f7b8aecae8cf8a2e0 to your computer and use it in GitHub Desktop.
Find files with contents matching a RegEx pattern
$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