Linux – How to find files within a size range

awkbashfindgreplinux

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.

Best Answer

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.

Related Question