I would like to ignore any files or folders under a specific folder when I am downloading from remove server with a foldername and wildcard.

I want to exclude all files or folders under "/*.old/" But this folder can exists in multiple places.

Do i have to specify the location with multiple entries like? Or this there a way that i can just exclude the old folder wherever it occurs?


Here is the command that I am using

rsync -amHAXxzvR --update --numeric-ids --progress  --include='*/' --include=*.sas7bdat --exclude='*.old/' --exclude=* -e "ssh -T -c blowfish-cbc -o Compression=yes -x" [email protected]:/XXX/ /mnt/z/XXX/.

I would like to exclude any folder and its subfolders with the name like /sasdata.old/ This folder can be located anywhere.

1 Answer 1


You just need to specify it as a directory that's not tied to the top of the source tree:

--exclude '*.old/'

Having now seen your full command it's clear why you still can't get it to work. Include and exclude options apply from left to right: for any given file or directory the first one that matches is the one that's applied. So in your case you need to exclude the directories you don't want before you include them all.

See my answer on Superuser for full details.

Try this,

rsync -aHAX -xu -z -v -R --numeric-ids --progress --prune-empty-dirs \
    --exclude='*.old/' --include='*/' \
    --include='*.sas7bdat' --exclude='*' \
    -e "ssh -T -c blowfish-cbc -x" \
    [email protected]:/XXX/ /mnt/z/XXX/.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .