| |
SAPIENScripter
Posts: 261
Score: 2
Joined: 11/1/2006
From: SAPIEN Technologies
Status: offline
|
Using -match will give you more hits without needing wildcards, which for you may be all that you need. You can still use wildcards, but be careful. Look at this: PS C:\test> dir | where {$_.name -match "test?.txt"} Directory: Microsoft.PowerShell.Core\FileSystem::C:\test Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 10/22/2007 9:59 AM 86 contest.txt -a--- 10/22/2007 10:06 AM 136 test.txt Compared to: PS C:\test> dir | where {$_.name -like "test?.txt"} Directory: Microsoft.PowerShell.Core\FileSystem::C:\test Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 8/29/2007 10:21 AM 126 test1.txt -a--- 8/29/2007 10:21 AM 136 test2.txt If I'm looking for files that start with test and then any single character, the latter approach is better. Powershell offers many ways to match and find strings, including regular expressions. Run: PS C:\test> help about_comparison_operators to learn more.
_____________________________
Jeffery Hicks Windows PowerShell MVP SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com
|
|