Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 am using rsyncrypto to backup a few of my user directories. I want to exclude some subdirectories from the encryption. I read that the best way to do this is to pipe the output of find to rsyncrypto.

Here's a find command that excludes directories named tmp:

find ~/Documents -type d -not \( -name tmp -prune \)

I have six or seven such directories to exclude. Is there a simple way for me to enumerate all of them in my find command?

share|improve this question
up vote 0 down vote accepted

You can use a regular expression:

find ~/Documents -type d ! \( -regex '.*/\(foo\|bar\|baz\)/?$' -prune \)

Keep in mind that the regex matches the whole directory/file structure not just the base name.

share|improve this answer

find ~/ -type d \! -name folder1 -and \! -name folder2

share|improve this answer

You must log in to answer this question.

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