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 have two same-size flash cards, and I want to copy contents of one to the other based on the following rules:

  1. I want all directories and subdirectories in place
  2. I want to exclude files of type .FOO, .BAR, and .ZIM (all other files are copied)
  3. Bonus: It'd be cool if it outputs the filenames as they are copied considering it will be copying ~8 GB of information

Could this be done with "find" somehow?

share|improve this question
You can edit your question and change the title. – Dennis Williamson Feb 5 '10 at 16:14
Ahh, there's the little "edit" link :) – macek Feb 5 '10 at 16:17
rsync is awesome :) – Rory Feb 5 '10 at 16:34
up vote 14 down vote accepted

This would be significantly easier using rsync with its --exclude switch.

rsync -av --exclude='*.FOO' --exclude='*.BAR' --exclude='*.ZIM' /source /dest

The -v switch will provide verbose output on which files are being synchronised.

share|improve this answer
Little follow-up here: the copy finished and /src/* is now in /dest/src/* How to use rsync to get /src/* in /dest/*? – macek Feb 5 '10 at 17:32
Try /source/ /dest – John T Feb 5 '10 at 17:44

If you have large number of extensions to exclude you can make a file and write down all the extension or file to exclude and use only one exclude option to make it simple.

rsync -ravz --exclude='./abc,txt' /source /dest

It is always good to use z for compression and r option if you have to copy recursively.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.