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 6 or 7 such directories to exclude, is there simple way for me to enumerate all of them in my find command?

link|improve this question
feedback

2 Answers

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.

link|improve this answer
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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