While I was trying to copy a load of files from one server to another I found a problem I’ve seen time and time again, rsync with filenames that have spaces in them. While normally this can be easily fixed via number of methods:
rsync ‘firstname.lastname@example.org:/remote/path/filename with spaces.txt’ /local/path/
Notice the quotes around the remote path, you can also use the -s (or –protect-args) which will send the command as-is to the remote.
Tonight I find this doesn’t seem to work (or I can’t get it to work) with a list of files (–files-from=LISTOFFILES.txt). After a few minutes of frigging around I decided there was only one thing for it… A bash for loop 🙂
IFS=$(echo -en “\n\b”)
for i in `cat LISTOFFILES.txt`
rsync -av ‘email@example.com:/path/to/files/”$i”‘ /local/path
This seemed to work quite nicely.
Edit: OK so it doesn’t seem to be working as well as I thought, seems to pull everything which is just weird…. come back for a fix soon!
Edit: So this is a bit strange, but seems to be working now. Removing the quotes seems to do the trick
#!/bin/bash SAVEIFS=$IFS IFS=$(echo -en "\n\b") for i in `cat LISTOFFILES.txt` do rsync -av firstname.lastname@example.org:/path/to/files/$i /local/path done