Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to run rsync on path with spaces

📅 2019-May-17 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive


When either or both of the source and destination paths in a rsync command has spaces, it does not work as expected:

$ rsync joe@foobar:"path/to/some thing" .
$ rsync joe@foobar:path/to/some\ thing .

Enclosing the path in double quotes (like shown above) or using slashes to escape the space does not work.


The reason the above solutions do not work is that the local shell is acting on the path and stripping its quotes or slashes before passing it to rsync.

So, we double up using both strategies and it works:

$ rsync joe@foobar:"path/to/some\ thing" .