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.

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

Thanks

share|improve this question
add comment

2 Answers

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
add comment
find . -type f \( ! -iname "*.bak" \)
share|improve this answer
add comment

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.