Search This Blog

2013-03-19

PowerShell: Equivalent to UNIX find/grep

Product: Windows PowerShell

I was trying to find out the PowerShell command that equivalent to following UNIX command to search through all files for a particular text (or regular expression)

find . | grep -i "family_picture"

The PowerShell equivalent is

Get-ChildItem -recurse | select-string -pattern "family_picture"

Default is not case sensitive, so no need to map "grep -i" parameter. If needed case sensitive, then it will be

Get-ChildItem -recurse | select-string -pattern "family_picture" -casesensitive

No comments: