exclude hidden files

Benjamin R. Haskell rsync at benizi.com
Sat Aug 20 10:58:59 MDT 2011

On Sat, 20 Aug 2011, Ken Gillett wrote:

> OK, thanks for that. For some reason that escapes me now, I was sure 
> that [--exclude '.*'] caused problems.
> I'll have a go with just '.*'.

My guess is that you were once trying to sync a directory containing 
hidden (dot) directories.  So, e.g.:

$ treeish somedir
  └─┬─ .hidden/
    │   ├── .hidden-file
    │   └── normal-file
    └─ normal/
        ├── .hidden-file
        └── normal-file

Even though normal-file in somedir/.hidden/ doesn't match '.*' it's 
excluded, because its parent directory ( somedir/.hidden/ ) has been 

In that case, you can add:

--include='.*/'   <-- include things matching .* which are directories
--exclude='.*'    <-- exclude things matching .*

Since includes trump later excludes, that keeps hidden directories, but 
discards hidden files.


More information about the rsync mailing list