Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie ? on Filtering Results of Get-ChildItem 1

Status
Not open for further replies.

thermidor

Programmer
Nov 28, 2001
123
US
Hi All:

I am new to PS. The line below almost does what I need... I want to recusively look in $Path and return every file that has the string "(1)" - open paren, digit one, close paren, in that sequence - in its name. With the command below, my results include files that have all three characters but not in sequence.

$wind =get-Childitem $Path -recurse | where{$_.name -match "(1)"}

Please let me know any suggestions.

TIA,
Sven
 
I've never been terribly good with regular expressions, but I think that's what's happening. It's getting interpreted as a regular expression, and needs to be escaped. Not sure how to do that, as inserting escape characters doesn't seem to fix it.

Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
 
whoops, actuall, for your example, it would be
Code:
$wind = Get-ChildItem $path -Recurse | ? {$_.name -match "\(1\)"}

Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
 
>$wind =get-Childitem $Path -recurse | where{$_.name -match "(1)"}
[tt]$wind =get-Childitem $Path -recurse | where{$_.name -match "[red]\[/red](1[red]\[/red])"}[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top