MicrosoftDocs / PowerShell-Docs

The official PowerShell documentation sources
https://learn.microsoft.com/powershell
Creative Commons Attribution 4.0 International
1.93k stars 1.55k forks source link

"?" wildcard behaviour #11104

Closed i5513 closed 2 months ago

i5513 commented 2 months ago

Type of issue

Missing information

Feedback

Seems like that, in Powershell 5.1, a filter ends in "?" it have a different behaviour?

Examples:

PS c:\> mkdir 11,11T | Out-Null ;  gci . -Attributes "Directory" -Filter "??????"

    Directorio: C:\Users\XXXX\borrar

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        14/05/2024      8:15                11
d-----        14/05/2024      8:15                11T
 C:\> rm -Force 1ddddd; mkdir 1ddddd | Out-Null ;  gci . -Attributes "Directory" -Filter "1????d?????????????????????"
    Directorio: C:\Users\XXXX\borrar

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        14/05/2024      8:31                1ddddd

Page URL

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-7.4

Content source URL

https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/7.4/Microsoft.PowerShell.Core/About/about_Wildcards.md

Author

@sdwheeler

Document Id

ff488242-1650-b2fd-c3a7-bec7ec1a8ee6

sdwheeler commented 2 months ago

For the filesystem, .NET matches ? to zero or one character in that position. For string comparisons, ? matches exactly one character in that position.