user3236362
user3236362

Reputation: 23

OSX Terminal Commands for find files with multiple criteria

I've try to find files that are greater than 1GB and are of a special type (e.g. *.avi, *.mov, *.mpeg). What I've tried until now is

find . -name "*.mpeg" -o -name "*.mkv" -o -name "*.avi" -o -name "*.mov" -size +1073741824 

But this seems not to work as it shows files that are <1GB. I'm sure that can't be that complicated but I just don't see the solution :(

Upvotes: 2

Views: 2719

Answers (1)

that other guy
that other guy

Reputation: 123490

find -cond1 -o -cond2 -cond3 will check for cond1 OR (cond2 AND cond3), not (cond1 OR cond2) AND cond3. In math and programming, conjunction always has precedence over disjunction.

To make it work the way you want, just add your own grouping:

find . \( -name "*.mpeg" -o -name "*.mkv" -o -name "*.avi" -o -name "*.mov" \) -size +1073741824

Upvotes: 9

Related Questions