Welcome to MSDN Blogs Sign in | Join | Help

jaredpar's WebLog

Code, rants and ramblings of a programmer.

Syndication

News

Now Reading

Expert F#

What's a better book to read when learning F#?

Essential WPF

Thus far the best book I've read on WPF. Gets right down to working with WPF and the goals/history.

Purely Functional Data Structures

Reading this book makes me feel like I'm back in college. It will really get your mind going and is best read with a whiteboard handy.

Blog Roll

Eric Lippert
Dustin Campbell
Jon Skeet
Coding Horror
Brian McNamara
Brian Bondy
Hub FS
Full List

Select-StringRecurse

When you need to search for text in a file, select-string is your best friend.  It has most of the functionality of old unix grep.  In addition it does full regular expression support.

The only downside is that it will only run on files in the current directory.  Unlike get-childitem, it has no recurse parameter.  In addition, I'm lazy and I don't like typing out select-string every time.  I have the following definitions in my Profile to make this easier. 

function Select-StringRecurse()
{
    param ( $text = $(throw "Need text to search for"),
            $filter = "*" )
    gci -re -in $filter | ? { -not $_.PSIsContainer } | % { ss $text $_ }
}  

set-alias ss    select-string
set-alias ssr   Select-StringRecurse

Published Monday, October 08, 2007 12:02 AM by Jared Parsons

Filed under:

Comments

# Techy News Blog » Select-StringRecurse @ Monday, October 08, 2007 12:09 AM

PingBack from http://www.artofbam.com/wordpress/?p=5995

Techy News Blog » Select-StringRecurse

# A smarter Select-StringRecurse @ Monday, January 21, 2008 7:15 PM

Previously I blogged about a recursive select-string function. Recently I've extended it a bit. I found

jaredpar's WebLog

# A smarter Select-StringRecurse @ Monday, January 21, 2008 7:34 PM

Previously I blogged about a recursive select-string function. Recently I've extended it a bit. I

Noticias externas

New Comments to this post are disabled
Page view tracker