Skip to content

Instantly share code, notes, and snippets.

@janbaer
Created June 20, 2013 09:46
Show Gist options
  • Save janbaer/5821550 to your computer and use it in GitHub Desktop.
Save janbaer/5821550 to your computer and use it in GitHub Desktop.
Find a specific content of a file with a regular expression in powershell
cls
$path = 'd:\Git\sp'
$file = '*.csproj'
$regex = "^.*(?=Output).*\.dll</HintPath>"
Get-ChildItem -Path $path -Name $file -Recurse | where {(get-Content $_ | Select-String $regex)}
@janbaer
Copy link
Author

janbaer commented Jun 20, 2013

This regular expression finds all files that contains a reference that not contains 'ThirdPartyLibraries'

<HintPath>(?!.*?ThirdPartyLibraries.*$)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment