You escape spaces in a remote path when using rsync over a remote SSH connection under Apple OS X / Linux or Unix like operating systems. [donotprint]
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | rsync |
Time | 1m |
Syntax
The syntax is as follows to copy a file called “/path/to/This is a test youtube video.mp4“:
rsync -av user@desktop:'This\ is\ a\ test\ youtube\ video.mp4' /path/to/here
OR
rsync -av 'user@desktop:This\ is\ a\ test\ youtube\ video.mp4' /path/to/here
You can also pass the -s or --protect-args option to avoid no space-splitting ( wildcard chars only ). The syntax is (note black slashes are removed with this option):
rsync -avs 'user@desktop:This is a test youtube video.mp4' /path/to/here
OR
rsync -av --protect-args 'user@desktop:This is a test youtube video.mp4' /path/to/here
OR
rsync -av --protect-args 'user@desktop:This is a test youtube video.mp4' '/path/to/My Download Folder'
To copy files to remote server called nas01 at /data/old.macbook.june-2013/MacMini/VirtualBox VMs/ folder type:
# cd to "$HOME/VirtualBox VMs/" # cd ~/VirtualBox\ VMs/ # Make a backup to nas01 server # rsync -avrPz . root@nas01:'/data/old.macbook.june-2013/MacMini/VirtualBox\ VMs/'
Sample outputs:
Fig.01: rsync over ssh when directory names have spaces on local or remote server
A note about older versions of rsync
If you are using an older versions of rsync Try the following syntax:
rsync -av user@server2:'dir1/file1 dir2/file2' /path/to/dest rsync user@macbook.local::'modname/dir1/file1 modname/dir2/file2' /path/to/here/dest
See also:
- BASH Shell: For Loop File Names With Spaces
- man page rsync
🐧 1 comment so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Hi,
Thanks, nice and useful article