Use rsync to copy only hidden files

I want to back up all hidden files and directories in my homedir using rsync, but not non hidden files and directories.

For example, this list of directories:

drwxr-xr-x   7 sophie  sophie  238 31 Mar 08:45 .
drwxr-xr-x  15 sophie  sophie  510 31 Mar 08:14 ..
-rw-r--r--   1 sophie  sophie    4 31 Mar 08:12 .foo
drwxr-xr-x   3 sophie  sophie  102 31 Mar 08:45 .hiddendir
drwxr-xr-x   4 sophie  sophie  136 31 Mar 08:13 VisibleDirectory
-rw-r--r--   1 sophie  sophie    9 31 Mar 08:13 VisibleFile

I want to back up .foo, .hiddendir and all the contents of .hiddendir, whether they are hidden or not. I do not want to back up VisibleDirectory or VisibleFile.

All the spells I invented support "." and therefore all its contents, including VisibleFile and VisibleDirectory, and I cannot figure out how to exclude it. Please, help!

I am using Mac OS X 10.5.6 (Leopard) and rsync version 2.6.9 version 29.

+5
source share
3 answers

.[^.]*

rsync -a ~/.[^.]* /path/to/backup

, . , , .

+6

".?? *", , ". ".."

( , , ".a"?)

+10

Have you tried avatars like. /.*?

Could you copy the hidden files to the temp directory, back up the temporary directory and delete it?

0
source

All Articles