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

Michael Paoli Michael.Paoli at cal.berkeley.edu
Mon Nov 19 09:04:29 PST 2018


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 [.].+

But among other bits, the specification is relatively
ambiguous/incomplete.
Non-recursively, or recursively?
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

> From: "Alex Kleider" <akleider at sonic.net>
> Subject: [sf-lug] how to copy all but dot files
> Date: Sat, 17 Nov 2018 19:06:10 -0800


> Just installed Ubuntu 18.04 on an old ThinkPad X301 and am tying to  
> copy files from my Ubuntu 16.04 machine.
> I'd like to exclude the dot files but how to get an expression that  
> will do this?
> ...so I began composing an email asking the list how this could be done.
> In the process of trying to ask the question in an appropriate  
> format, I actually came up with a solution on my own.  I've decided  
> to post it any way thinking it might help some one else or (perhaps  
> more likely) it might prompt others more expert to offer a better way.
>
>     rsync -av --exclude [.].+ user@<IP>:~/ <destination-directory>




More information about the sf-lug mailing list