【发布时间】:2016-02-11 09:43:28
【问题描述】:
是的,我确实意识到如何在 scp 中转义 空格 已经被问了一千次了,但是我没有使用 &-符号来做到这一点,所以如果该符号是目录名称的一部分。
[sorunome@sorunome-desktop tmp]$ scp test.txt "bpi:/home/sorunome/test & stuff"
zsh:1: command not found: stuff
lost connection
& 符号似乎有点搞砸了,使用 \& 并不能解决问题,因为找不到远程目录:
[sorunome@sorunome-desktop tmp]$ scp test.txt "bpi:/home/sorunome/test \& stuff"
scp: ambiguous target
即使省略引号并在所有工作的地方添加 \ 也不行:
[sorunome@sorunome-desktop tmp]$ scp test.txt bpi:/home/sorunome/test\ \&\ stuff
zsh:1: command not found: stuff
lost connection
那么,有什么想法吗?
【问题讨论】:
-
必须使用 zsh 吗?我在 bash 下尝试过,它没有任何额外的转义就可以工作。
-
不,我不必使用 zsh,我只是用 bash 尝试了它,它产生了相同的效果(而不是它说“zsh:1”现在说“bash”)另外,只是因为很感兴趣,我刚刚尝试了
scp test.txt "bpi:/home/sorunome/test & touch test.tmp",它确实在我的远程家中创建了文件 test.tmp!