Help with complicated heirarchy exclude syntax

Matt McCutchen matt at
Wed Dec 26 00:53:02 GMT 2007

On Tue, 2007-12-25 at 15:52 -0600, reader at wrote:
> None of these seem to get to the wanted files:
> rsync -navv --prune-empty-dirs --exclude='/nntp/**/' \
> --include='/nntp/**[!a-zA-Z]*' --exclude='/nntp/**' \
>           ~/projects/backup/rsync/nntp ./here/

The first filter needs to be an include, not an exclude.

> I wasn't sure where to `prepend' at but I've tried just about all
> positions by now.

Before the other filters, as in the example I quoted.  The point is that
it needs to take priority over the subsequent exclude filter.

> Alpha named files will occur throughout the
> heirarchy ... (nntp nov files) with names like .agentview or
> .overview.

Note: those files have dots in their names in addition to letters, so
you would need to put a dot in the character class.  But see below...

> Maybe others from other sources such as me in there with emacs leaving
> files like `121~'  or `file~' somewhere in the heirarchy.  Some are
> likely to very large... the result of cat *[65]* > monsterfile
> I want to move the actual news posts to an accumulative archive where
> those nov files would contain all the wrong information and be a
> hazard because of it.  Not to mention they can grow truely huge when a
> directory may contain 10s of thousands of messages.  

Then maybe you want to take only entirely numeric files (the exact
opposite of your original scenario) rather than all files except
entirely alphabetic ones.  To do that, you should replace
--include='/nntp/**[!a-zA-Z]*' --exclude='/nntp/**' with
--exclude='/nntp/**[!0-9]*' .


More information about the rsync mailing list