problem getting just a single dir !

Wayne Davison wayned at
Mon Feb 11 18:02:06 EST 2002

On Sun, 10 Feb 2002, Nishikant Kapoor wrote:
> I am trying to fetch a single dir using the following command but all I
> get is a empty dir:
> rsync -av --include=myDir --exclude=* .

Includes are tricky that way -- you told it to just include the
directory, but you didn't tell it to include anything within the
directory.  This is because --exclude=* excludes everything at every
level that didn't get explicitly mentioned (I'm assuming you protected
the '*' so that it didn't get expanded by the shell).

The easiest way to accomplish what you want is to do to just name the
directory without using the include/exclude options:

rsync -av .

If you want to use include & exclude, you could do this:

rsync -av --include=/myDir --exclude=/* .

This tells rsync to only exclude the items at the base of the path that
are not myDir, not all items at all levels.  Alternately, you could do

rsync -av --include=/myDir** --exclude=*

Where you explicitly include everything within myDir (the "**" matches
slashes, so it includes subdir content as well, and the initial '/' is
required for it to match the whole path).


More information about the rsync mailing list