5

Please suggest me the way to find all the zip files which are more than 60 MB but less than 70 MB in size using 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 '15 at 14:44
7
find -iname "*.zip" -size +$((60*1024*1024))c -size -$((70*1024*1024))c

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

from the info documentation section 2.4 Size

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

so 69.001 gets rounded up to 70 and thus gets excluded!

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

2
  • 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 '19 at 19:32
  • This hint is soooo good!
    – halloleo
    Aug 27 '19 at 4:26
6
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 '18 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.