tags:

views:

134

answers:

1

I want to perform a find command in a directory, and exclude from the set of results all files that are .gif, .jpeg, and .class.

I was wondering if someone could help me out. I've been trying to play with the regex option, but clearly I'm not doing it properly.

+4  A: 

Something like:

find . \! -name '*.class' \! -name '*.jpeg' \! -name '*.class'
Charles Bailey
similar: find ./ -type f -and -not -name ".gif" -and -not -name "*.jpeg" -and -not -name "*.class"
AJ
@AJ: Similar, yes, but personally I don't see a reason to type more and reduce portability.
Charles Bailey
@Charles Bailey - thanks for the feedback.
AJ
its also better to enclose the -name with braces. \( -name .... -name \)
ghostdog74
@ghostdog74: If you enclose the name clauses in braces (bringing the '\!' outside) then you must use `-o` as well, e.g. `find . \! \( -name '*.class' -o -name '*.jpeg' -o -name '*.class' \)` otherwise the condition would not longer be correct. If that isn't what you meant I'm not sure how the `\(` and `\)` aren't redundant in this case?
Charles Bailey