Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - grep -r equiv

Reply
 
Old 05-14-2007   #1 (permalink)
Frank


 
 

grep -r equiv

Hi,

What is the preferred method to doing the equivalent of "grep -r". I tried:

get-childitem *.ps1 | get-content | select-string "somestring" but it seems
to only get the top level .ps1 sripts.

thanks in advance,



My System SpecsSystem Spec
Old 05-14-2007   #2 (permalink)
Brandon Shell


 
 

Re: grep -r equiv

this should work. This will list every file and add the lines if found.. you
can change that of course.

get-childitem *.ps1 -recurse | %{get-content $_.FullName;Write-Host
$_.FullName} | select-string "somestring"

"Frank" <Frank@discussions.microsoft.com> wrote in message
news:EA70370B-B79A-4015-A77D-A80DEE37319B@microsoft.com...
> Hi,
>
> What is the preferred method to doing the equivalent of "grep -r". I
> tried:
>
> get-childitem *.ps1 | get-content | select-string "somestring" but it
> seems
> to only get the top level .ps1 sripts.
>
> thanks in advance,
>
>


My System SpecsSystem Spec
Old 05-14-2007   #3 (permalink)
Frank


 
 

Re: grep -r equiv

That does not appear to work. I purposely put subdirs there and I had to do:

get-childitem *\*.ps1 -recurse

to find them. What gives?



"Brandon Shell" wrote:

> this should work. This will list every file and add the lines if found.. you
> can change that of course.
>
> get-childitem *.ps1 -recurse | %{get-content $_.FullName;Write-Host
> $_.FullName} | select-string "somestring"
>
> "Frank" <Frank@discussions.microsoft.com> wrote in message
> news:EA70370B-B79A-4015-A77D-A80DEE37319B@microsoft.com...
> > Hi,
> >
> > What is the preferred method to doing the equivalent of "grep -r". I
> > tried:
> >
> > get-childitem *.ps1 | get-content | select-string "somestring" but it
> > seems
> > to only get the top level .ps1 sripts.
> >
> > thanks in advance,
> >
> >

>
>

My System SpecsSystem Spec
Old 05-14-2007   #4 (permalink)
Brandon Shell


 
 

Re: grep -r equiv

get-childitem requires path (at least as far as I can tell) for recursion.

What I did was:
get-childitem $mypath *.ps1 -recurse

"Frank" <Frank@discussions.microsoft.com> wrote in message
news:0AC67253-E72D-492B-8DD3-57D411F3F50E@microsoft.com...
> That does not appear to work. I purposely put subdirs there and I had to
> do:
>
> get-childitem *\*.ps1 -recurse
>
> to find them. What gives?
>
>
>
> "Brandon Shell" wrote:
>
>> this should work. This will list every file and add the lines if found..
>> you
>> can change that of course.
>>
>> get-childitem *.ps1 -recurse | %{get-content $_.FullName;Write-Host
>> $_.FullName} | select-string "somestring"
>>
>> "Frank" <Frank@discussions.microsoft.com> wrote in message
>> news:EA70370B-B79A-4015-A77D-A80DEE37319B@microsoft.com...
>> > Hi,
>> >
>> > What is the preferred method to doing the equivalent of "grep -r". I
>> > tried:
>> >
>> > get-childitem *.ps1 | get-content | select-string "somestring" but it
>> > seems
>> > to only get the top level .ps1 sripts.
>> >
>> > thanks in advance,
>> >
>> >

>>
>>


My System SpecsSystem Spec
Old 05-15-2007   #5 (permalink)
Flowering Weeds


 
 

Re: grep -r equiv


"Frank"

>
> What is the preferred method


Preferred?

> to doing the equivalent of "grep -r".
>


Well since grep is a process then perhaps
doing the same is running another process
too!

PS> LogParser -h -i:textline | select-string "recurse"

-recurse <level> : Max subdirectory recursion level
(0=no recurse, -1=all levels)

PS> LogParser "SELECT Text FROM '$pwd\*'
WHERE Text LIKE '%recurse%' "
-i:textline -recurse:" -1" -rtp:5 -statsff
Text
--------------------------------------------
ESC " -i:fs -recurse:0 -rtp:" -1" -statsff
-i:fs -recurse:0 -rtp:" -1" -statsff

Just another way!





My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Find and GREP PowerShell
Grep Vista file management
select-string to act like grep -v PowerShell
sfc /scannow or equiv in Vista? Vista performance & maintenance


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46