Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to sync a large tree on Linux, but include and exclude certain files/directories. My question is regarding rsync's --relative option and how relative paths are handled. Directory structures appear something like:


I want to transfer directories and files under 'company?' non-recursively. This (so far) appears to do what I am after:

rsync -a --relative /x/./z? --include '/x/*/*/*' --exclude '/x/*/*/*/*' a@b:/x

How could I specify the inc/excl rules as relative paths? What would this do?

rsync -a --relative /x/./z? --include '*/*/*/*' --exclude '*/*/*/*/*' a@b:/x

How will the patterns match? In order words, are the patterns relative to /x or to /x/./z ?

share|improve this question
Please remember to include your operating system in your question. Is this Linux, AIX, UNIX, OSX, BeOS, what? – terdon Jul 6 '13 at 12:53
linux. added to OP. thank you. – Felipe Alvarez Jul 7 '13 at 23:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.