![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Has select-string changed behavior with RC2? I have previously (some months ago, earlier PS build) used a command such as get-content *.ps1 | select-string function -list | % { $_.path } (trying to list all the files in current directory that have functions defined in them). This used to give me the filenames. Now all I get is output like this InputStream InputStream InputStream InputStream InputStream ..... (one line for each file that select-string finds with a match) select-string produces a stream of MatchInfo objects; but why does the path field of the MatchInfo object not identify the filename? MatchInfo also has a filename property; it behaves the same. I see that I can achieve my goal directly with select-string thus: select-string -path *.ps1 -list | % { $_.path } which is fine for this simple case - but what if I need something more complex earlier in the stream to identify the set of files to be searched? For example, I want to find all such files in a directory tree and search them: get-childitem -path *.ps1 -recurse | get-content | select-string function -list | % { $_.path } |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Has select-string changed behavior with RC2? I think you probably used "Get-Item" to start the pipeline. Lee "forestial" <forestial@discussions.microsoft.com> wrote in message news 3842C0C-0810-4065-8525-7411B44E0AE8@microsoft.com...>I have previously (some months ago, earlier PS build) used a command such >as > > get-content *.ps1 | select-string function -list | % { $_.path } > > (trying to list all the files in current directory that have functions > defined in them). > > This used to give me the filenames. Now all I get is output like this > > InputStream > InputStream > InputStream > InputStream > InputStream > > .... (one line for each file that select-string finds with a match) > > select-string produces a stream of MatchInfo objects; but why does the > path > field of the MatchInfo object not identify the filename? MatchInfo also > has > a filename property; it behaves the same. > > I see that I can achieve my goal directly with select-string thus: > select-string -path *.ps1 -list | % { $_.path } > > which is fine for this simple case - but what if I need something more > complex earlier in the stream to identify the set of files to be searched? > For example, I want to find all such files in a directory tree and search > them: > > get-childitem -path *.ps1 -recurse | get-content | select-string function > -list | % { $_.path } |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Has select-string changed behavior with RC2? Ouch! You are correct. My memory is bad, and my notes are worse. "Lee Holmes [MSFT]" wrote: > I think you probably used "Get-Item" to start the pipeline. > > Lee > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Select-String -exclude | Paul Farrimond | PowerShell | 7 | 08-18-2008 10:35 AM |
| Strange behavior regarding here-string and backtick | GS | PowerShell | 9 | 07-29-2008 02:00 AM |
| problems with $var | select-string -pattern $string -q | Ben Christian | PowerShell | 3 | 02-08-2008 12:41 PM |
| select-string and .split | alicain | PowerShell | 3 | 10-12-2007 11:01 AM |
| Re: select-string exceptions | cmyers | PowerShell | 2 | 05-23-2007 06:06 PM |