Tricky Quoting Issue in BASH

Dave Smith DavidSmith at byu.net
Sun Jan 1 13:27:48 MST 2006


Charles Curley wrote:

>I'd like to run an rsync command to do backups, with an exclude
>pattern. I can build what looks like a perfectly good command, echo
>it, then run it. But the exclude pattern is ignored. However, if I
>copy the echoed command line and execute it directly, it works and the
>exclude pattern is respected.
>
>Something like:
>
>
>    # options to feed to rsync
>
>    opts="-va --exclude '*~' --delete --delete-excluded"
>
>    ....
>
>
>    cmd="rsync $opts $internal$back/ $external$back"
>
>    echo $cmd
>
>    $cmd
>
>  
>
When I do this, I always stick the ignore patterns in a file and use the 
--exclude-from=myfile.txt option. It's the only way I've found to make 
it behave consistently.

--Dave



More information about the PLUG mailing list