Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

old rsync and spaces in filenames

Source directory is determined like so:

SHOW=${PWD##*/}
[email protected]:"/mnt/bigfish/video/TV/${SHOW}/"

So it comes out something like:

[email protected]:/mnt/bigfish/video/TV/The Name Of the Show With Spaces/

Then trying to run rsync like so:

rsync -avz -e ssh "${SRC}" .

But it tells me that ""/mnt/bigfish/video/TV/The" is not a directory, ""/mnt/bigfish/video/TV/Name" is not a directory, etc, for however many space-delimited words are in the name of the source directory.

How can I rectify this egregiously annoying issue?

UPDATE I'm running this on OS 10.6, and I ended up string-replacing spaces with escaped spaces like so:

[email protected]:"/mnt/bigfish/video/TV/${SHOW// /\ }/"
like image 526
Wells Avatar asked Jul 26 '10 00:07

Wells


2 Answers

From the rsync manual:

-s, --protect-args
This option sends all filenames and most options to the remote rsync without allowing the remote shell to interpret them. This means that spaces are not split in names, and any non-wildcard special characters are not translated (such as ~, $, ;, &, etc.). Wildcards are expanded on the remote host by rsync (instead of the shell doing it).

like image 150
msw Avatar answered Oct 04 '22 03:10

msw


As your question is dedicated to OS X, according to the Apple rsync manual you can accomplish this using either simple quotes or the wildcard ?:

rsync -av host:'file\ name\ with\ spaces' /dest
rsync -av host:file?name?with?spaces /dest

Just had to do this and using the simple quotes works perfectly:

rsync -r --partial --progress --exclude=".cvs" --exclude=".svn" --exclude=".git" --rsh=ssh [email protected]:'/volume1/devel/__To\ SORT/___XXXXX\ Saves\ 2011-04' ./Saves2011
like image 26
Coyote Avatar answered Oct 04 '22 02:10

Coyote