Monday, June 19, 2017

Find a File with Certain Contents

I was trying to search for a file with a particular class name inside it, and I could not remember the syntax of the command to save my life.  I knew I had it in a note somewhere, but I couldn't find that either.

Tonight I found the note.  I'm posting the command here so I can find it again.

For linux:
find . -name 'filepattern' -exec grep -l 'contentpattern' {} \;
For Powershell:
Get-ChildItem -Recurse | Select-String "dummy" -List | Select Path

No comments:

Post a Comment