我試圖搜索目錄c:\bats\
包含UNC路徑的批處理文件\\server\public
選擇字符串轉義字符
命令:
Get-ChildItem -path c:\bats\ -recurse | Select-string -pattern "\\server\public"
我收到相關的字符串\\server\public
錯誤:
Select-string : The string \\server\public is not a valid regular
expression: parsing "\\server\public" - Malformed \p{X} character
escape. At line:1 char:91
+ ... ts" -recurse | Select-string -pattern \\server\public
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Select-String], ArgumentException
+ FullyQualifiedErrorId : InvalidRegex,Microsoft.PowerShell.Commands.SelectStringCommand
我試過使用各種轉義,如"\server\public"
或"'\server\public'"
,但我總是收到t帽子同樣的錯誤。
謝謝,這就像一個魅力工作! – rob 2015-02-05 20:52:17
如果模式是可變的,該怎麼辦? – 2018-02-05 15:48:30