我试图搜索目录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