Monday 11 June 2012

Find and grep in powershell

Find and grep is easy. Powershell is slightly annoying.

#find some files by extension and grep
gci . -Recurse | where{$_.Extension -match "vb|resx|aspx"} | select-string -pattern "someTerm" -caseSensitive

#find all and grep
gci . -Recurse | select-string -pattern "someTerm" -caseSensitive

#find and grep webmethods files
gci . -Recurse | where{$_.Extension -match "xml|ndf"} | select-string -pattern "someTerm" -caseSensitive

No comments:

Post a Comment