Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

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.