[sf-lug] how to copy all but dot files

Alex Kleider akleider at sonic.net
Wed Nov 21 17:40:49 PST 2018


On 2018-11-19 09:04, Michael Paoli wrote:
> Well, if you want [.].+ to be interpreted by rsync, rather than the 
> shell,
> you should quote at least the [ and ] characters, e.g.:
> '[.].+'
> \[.\].+
> etc.
> Otherwise, if you have a file named ..+ in the current directory,
> then rsync will see ..+ rather than [.].+

Thanks, Michael, for the input.  I should have realized that the regular 
expression must be protected from the shell and passed as is to rsync.
So my modified version becomes:
      rsync -av --exclude '[.].+' user@<IP>:~/ <destination-directory>

> 
> But among other bits, the specification is relatively
> ambiguous/incomplete.
> Non-recursively, or recursively?

Not sure what you mean here but assume you mean whether or not to copy 
directories and everything in them.
I believe the '-a' option of rsync does this.

With regard to metadata such as ownership, permissions, etc, I believe 
rsync takes care of that 'intelligently.'


> If recursively:
>   cross filesystem mount points, or not?
>   also exclude . itself ?
> Files of any type or just of type "ordinary" file?
> And if not crossing filesystem mount points, include the mount points
> themselves, or skip those?
> Preserve ownerships/permissions and mtime to the extent permitted?
> What if the target exists?
> What if the target exists and has same length, mtime,
> ownerships and permissions?  Presume it's the same, or make it the 
> same?  (
> Note that by default rsync will presume in such case the data matches
> and won't even calculate hash on the target file).
> 
> Anyway, I might do something roughly like:
> $ find . \( -type d ! -name . -prune \)  -o \( ! -name '.*' \) -print0
>  | pax -rw -0d -p p target_directory

I'm not versed enough in bash and shell scripting to follow what's going 
on above.


Cheers,
Alex



More information about the sf-lug mailing list