So I am writing a bash script to automatically rsync around 40 different directories to 40 other directories on another server.
If you want to read my whole script you can find it here:
http://pastebin.com/uph49vHd
However the important bit is as follows:
Code:
for ((i=0; i<1; i++))
do
localpath="'/nusdata/staff/NUS/NUS/Systems/${kiskasys[$i]}'"
remotepath="/home/www/html/systems/${websys[$i]}"
rsync -rlptnvz -s "$localpath" -e "ssh -p 50014" "nusak@webserver:$remotepath/"
done
Where kiskasys is an array of directory names and websys is an array of corresponding directory names.
The problem is that kiskasys is full of directory names with spaces.
Now I can easily change how those directory names are put into the array, say by adding escaped spaces like '\ ' or by adding quotes around it etc but i have tried all different combinations of this and still have yet to make it work.
Here is an example of what the rsync command would look like if i didnt use variables:
Code:
rsync -rlptnvz -s "nusdata/staff/NUS/NUS/Systems/101 greenbrook/" -e "ssh -p 50014" "nusak@webserver:/foo/bar"
note that the only directory with spaces would be the local directory.
Any help on how to make this work would be appreciated!!
Thanks