此命令在 bash 中工作正常:
bash-3.2$ scp luna4:/u/paige/maye/src/diviner/notebooks/plots/hk_* .
hk_az.png 100% 126KB 126.0KB/s 00:00
hk_baffle.png 100% 166KB 166.3KB/s 00:01
hk_bb.png 100% 144KB 143.8KB/s 00:00
hk_el.png 100% 115KB 115.3KB/s 00:00
hk_fpa.png 100% 123KB 123.2KB/s 00:00
hk_fpb.png 100% 126KB 125.7KB/s 00:00
hk_hybrid.png 100% 99KB 98.7KB/s 00:00
hk_oba.png 100% 140KB 139.7KB/s 00:00
hk_solar.png 100% 206KB 205.6KB/s 00:00
hk_temp.png 100% 62KB 61.8KB/s 00:00
hk_yoke.png 100% 122KB 121.7KB/s 00:00
bash-3.2$ exit
Run Code Online (Sandbox Code Playgroud)
但是在 zsh 中它失败了,找不到文件:
$ scp luna4:/u/paige/maye/src/diviner/notebooks/plots/hk_* .
zsh: no matches found: luna4:/u/paige/maye/src/diviner/notebooks/plots/hk_*
Run Code Online (Sandbox Code Playgroud)
出了什么问题?
Ell*_*sch 29
问题是,zsh
是通配的远程路径。您可以通过以下方式验证
scp luna4:"/u/paige/maye/src/diviner/notebooks/plots/hk_*" .
Run Code Online (Sandbox Code Playgroud)
要为 scp 远程路径关闭通配符,但否则保持通配符相同(从此处)将其添加到您的.zshrc
-
# Disable globbing on the remote path.
alias scp='noglob scp_wrap'
function scp_wrap {
local -a args
local i
for i in "$@"; do case $i in
(*:*) args+=($i) ;;
(*) args+=(${~i}) ;;
esac; done
command scp "${(@)args}"
}
Run Code Online (Sandbox Code Playgroud)