You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove-Item and Move-Item don't support escape characters in wildcard patterns on Unix #3725
Wildcard patterns- at least in the context of Get-Item - support ` as the escape character to represent literal ` instances in a path and to escape the following metacharacters: * ? [ ]
Remove-Item and Move-Item currently do not support that, neither with -Path nor with -Include.
Steps to reproduce
# Create a file that contains a literal backtick and a literal substring that would be a valid# sub-pattern if interpreted as a wildcard expression.New-Item-Type File 'a`[b]'# Match the newly created file using a wildcard expression with suitable escaping.Remove-Item*-Include 'a```[b`]'-WhatIf
Remove-Item-Path 'a```[b`]'-WhatIf
Move-Item*-Include 'a```[b`]'/tmp -WhatIf
Move-Item-Path 'a```[b`]'/tmp -WhatIf
Expected behavior
Both commands in each pair should find the target file and output information about how it would be deleted / moved.
Actual behavior
All commands unexpectedly fail to find the file:
Remove-Item : An object at the specified path /Users/jdoe/a`[b] does not exist.
...
Curiously, the error message quotes the correct literal path that it claims doesn't exist.
Move-Item's symptoms differ:
Move-Item : Cannot move item because the item at '...' does not exist.
...
Move-Item : The specified wildcard character pattern is not valid: a\[b
Curiously, all existing files in the directory (even those that don't match the pattern) are reported as non-existent.
Environment data
PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on macOS 10.12.4
PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Ubuntu 16.04
changed the title [-]Remove-Item doesn't support escape characters in wildcard patterns on Unix[/-][+]Remove-Item and Move-Item don't support escape characters in wildcard patterns on Unix[/+]on May 8, 2017
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 23, 2023
Activity
iSazonov commentedon May 8, 2017
Is Move-Item affected too?
[-]Remove-Item doesn't support escape characters in wildcard patterns on Unix[/-][+]Remove-Item and Move-Item don't support escape characters in wildcard patterns on Unix[/+]mklement0 commentedon May 8, 2017
Ilya (@iSazonov): Good point; yes,
Move-Itemis affected too - I've retitled and revised the original post accordingly.microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.