Bash — Rsync variable in filename has spaces

帅比萌擦擦* 提交于 2019-12-05 21:51:17

For what it's worth, I'm not able to replicate your problem. If I set localpath and remotepath to a directory with spaces:

localpath="/home/lars/tmp/so/dir1/a directory"
remotepath="/home/lars/tmp/so/dir2/a directory"

And then run your rsync command (modified slightly for my environment):

rsync -rlptvz -s "$localpath/" -e "ssh" "localhost:$remotepath/"

It Just Works. Here's the content of dir1:

dir1/a directory/file1
dir1/a directory/file3
dir1/a directory/file2

And after running rsync, dir2 looks like this:

dir2/a directory/file1
dir2/a directory/file3
dir2/a directory/file2

Can you show a specific command line that results in the errors you're seeing above? Maybe run the script with the -x flag and show exactly how localpath and remotepath are set.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!