只要路径中没有空格,我就可以通过 SSH 成功进行 RSYNC。
当路径确实有空格时,它不起作用。我试过斜线、引号和双引号。
当我使用斜杠时,输出表明它是成功的,但我没有看到任何传输的文件。
rsync -avz /path\ with\ spaces/ user@remotelocation:/media/another\ path\ with/spaces/
Run Code Online (Sandbox Code Playgroud)
当我使用单引号或双引号时,它告诉我输入密码后权限被拒绝
rsync -avz '/path with spaces/' 'user@remotelocation:/media/another path with/spaces/'
Run Code Online (Sandbox Code Playgroud)
我能做什么?
谢谢你。
小智 14
使用示例代码和参考扩展 rzr 的答案,只需添加-s标志,引用路径,而不必担心在远程路径中转义空格:
rsync -avzs '/path with spaces/' 'user@remotelocation:/media/another path with/spaces/'
Run Code Online (Sandbox Code Playgroud)
作为参考,OP 指定的选项:
需要的附加参数:
hee*_*ayl 13
您需要在本地 shell 和远程 shell 中转义空格。尝试这个:
rsync -avz '/path with spaces/' 'user@remotelocation:/media/another\ path\ with/spaces/'
Run Code Online (Sandbox Code Playgroud)
/path with spaces/本地shell中的源只能通过在其周围加上单引号来转义,即'/path with spaces/'.
另一方面,在目的地的情况下,本地 shell 通过放置单引号进行转义,而在远程 shell 中通过\在空格前面使用转义字符 ( ) 来对空格进行转义。