9

Please suggest a way to find all the zip files which are more than 60 MB but less than 70 MB in size using the find command.

1
  • Welcome to Super User. We are not a script writing service. We expect users to tell us what they have tried so far (including any scripts they are using) and where they're stuck so that we can help with specific problems. Questions that only ask for scripts are too broad and are likely to be put on hold or closed. Please read How do I ask a good question?.
    – DavidPostill
    Dec 18, 2015 at 14:44

3 Answers 3

12
find -iname "*.zip" -size +$((60*1024*1024))c -size -$((70*1024*1024))c

Do NOT use the abbreviations 60M and 70M as this will also exclude all files of size greater than 69MB including 69.001MB!

From the info documentation, section "Size":

-- Test: -size n[bckwMG]
    True if the file uses n units of space, rounding up.
    ...

Meaning, 69.001 gets rounded up to 70 and thus gets excluded!

A perfect example is find . -size -1M which will only match files of size zero.

1
  • Yeah I'm experiencing this quirk now when trying to bucketize my video files. Some sizes just don't fall into any bucket. Jan 30, 2019 at 19:32
8
find -iname "*.zip" -size +60M -size -70M

You can also use -o to get a disjunction, and \( … \) to group various matches.

-1

The same as you mentioned, but with -a. This should work

find / -type f -size +100M -a -size -200M -exec du -sh {} \;

1
  • 1
    Things to consider: (1) I think your answer adds nothing new, because -a is the default operator, the other answer uses it implicitly. If your answer explained this behavior along with other parts of the find syntax, then it would be of some value. In my opinion for now it's just an unnecessarily complex (why -exec du?) general (no zip-related filter) alternative. (2) The other answer is a community wiki. It's like an invitation to improve it instead of writing a concurrent answer; so if you really have something to add, the best thing to do is to edit the community wiki answer. Jun 28, 2018 at 5:44

You must log in to answer this question.

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