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

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
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

You must log in to answer this question.

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