bash - rsync script expands variable incorrectly -


i have script takes in unique location number file. these formatted 7325-05, 5269-09 , 7479-14, example. first 4 numbers folder called , second number first 2 characters of filename unique within each folder.

so wrote script use locate , find full path of folder , use wildcard download specific file using rsync. here's script have right now:

#!/bin/bash  #ifs=' #' oifs=$ifs ifs=$'\n'  while read line;     name=$line;     folder=${line:0:4}     track=${line: -2}     folderlocation="$(locate -r '/'$folder'$')"     filelocation="$(find "$folderlocation" -type f -name "$track*")"     rsync -vazhn --progress "$filelocation" /cygdrive/c/ #    mkdir /cygdrive/c/test/"$folder" #    cp -rvi "$filelocation" /cygdrive/c/test/"$folder"      echo ""; done < $1 

the code using cp commented out works fine. prefer use rsync, due better feedback , more accurate progress reporting, far can tell.

using code pasted above (with rsync) throws error:

./filelocator classic-locations.txt sending incremental file list rsync: change_dir "/home/emil//\\sandrew-nas/smmusic/mmimusic/7001-8000/7201-7300/7252/unknown album (29-12-2012 09-52-02)" failed: no such file or directory (2)  sent 20 bytes  received 12 bytes  64.00 bytes/sec total size 0  speedup 0.00 (dry run) rsync error: files/attrs not transferred (see previous errors) (code 23) @ main.c(1165) [sender=3.1.1]  sending incremental file list rsync: change_dir "/home/emil//\\sandrew-nas/smmusic/mmimusic/7001-8000/7201-7300/7252/unknown album (29-12-2012 09-52-02)" failed: no such file or directory (2)  sent 20 bytes  received 12 bytes  64.00 bytes/sec total size 0  speedup 0.00 (dry run) rsync error: files/attrs not transferred (see previous errors) (code 23) @ main.c(1165) [sender=3.1.1] 

as can see, home folder (where issue command) included in script, leading me believe variable or wildcard being expanded in local shell, no amount of escape characters seem accomplish want rsync.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -