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

Unlike the --exclude parameter for rsync that can excludes both files and directories, the *nix find command's -prune parameter can only exclude directories.

So how can I exclude a certain type of files (say .bak) when invoking find?
In other words, how to make the following non-working example works?

find --exclude=*.bak /some/dir


share|improve this question

2 Answers 2

up vote 1 down vote accepted

If I understand the question properly, the following will work:

find /some/dir \! -name '*.bak'
share|improve this answer
For my case, I'd use -iname, just FTA. – xpt Jun 30 '13 at 22:10
find . -type f \( ! -iname "*.bak" \)
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.