The Powershell equivalent to grep

I’m posting this mainly for my own use, since I keep forgetting the syntax. To search for a string in a source code tree, the command would look something like this:

Get-ChildItem -filter *.cs -recurse | Select-String -pattern "SearchTerm" -casesensitive

Plus or minus options, of course. You can also specify a base path for Get-ChildItem if required.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s