【发布时间】:2020-01-24 22:42:37
【问题描述】:
我正在尝试在 powershell 中使用 gsutil rsync 将文件复制到 gs 存储桶,忽略了一些文件扩展名,但我收到错误消息,指出 '.*.scss' 不是命令:
PS W:\> gsutil -m rsync -x ".*^.gz$^|.*^.scss$^|.*^.less$^|.*^.pdf$^|.*^.zip$" -d -r ./ gs://BUCKET
'.*.scssecho' is not recognized as an internal or external command
operable program, or a batch file.
# With the originally proposed solution:
PS W:\> gsutil -m rsync -x '.*\.(gz|scss|less|pdf|zip)$' -d -r ./ gs://BUCKET
'scss' is not recognized as an internal or external command,
operable program, or a batch file.
documentation 指示使用 ^ 作为转义字符而不是 \ 并转义 | 字符。我错过了什么?
【问题讨论】:
-
this >>>
NOTE: When using this on the Windows command line, use ^ as an escape character instead of \ and escape the | character. -
@Lee_Dailey,是的。它在cmd中也不起作用。
-
是的,powershell 正在尝试解释双引号中的 $,所以请改用单引号。
-
@js2010 单引号也一样。
-
请注意,gsutil.cmd 是一个 .bat 脚本。我相信这些引用问题之前已经出现过。
标签: windows powershell escaping parameter-passing gsutil