How to exclude files using find

4

1

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

xpt

Posted 2013-06-30T14:04:06.443

Reputation: 5 548

Answers

2

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

find /some/dir \! -name '*.bak'

rici

Posted 2013-06-30T14:04:06.443

Reputation: 3 493

For my case, I'd use -iname, just FTA. – xpt – 2013-06-30T22:10:28.133

1

find . -type f \( ! -iname "*.bak" \)

vujke

Posted 2013-06-30T14:04:06.443

Reputation: 223