Find Files by Size

Let's use the command find find files that are smaller, equals or bigger than a specific size. The command find is already inside Linux so you shouldn't have to install anything.

find will only need three arguments, the path, a type and the size.

The path is pretty obvious. The type, simply use f to specify it's a file. For the size is a little bit different.

Smaller or Bigger than

    (absence of symbol) reprensents that we want to find file of a specific size.
+   (plus symbol) means that we want to find files that are bigger than the specified size.
-   (minus symbol) means that we want to find files that are smaller than the specified size.

Size flags

b   for 512-byte block (default)
c   for bytes (aka characters)
w   for 2-bytes (aka word)
k   for Kilobytes
M   for Megabytes (note: the capital M)
G   for Gigabytes (note: the capital G)

Examples

Let's find all the files that have less than 100 characters, in the current directory

find . -type f -size -100c

Let's find all the files that are more than 1 Megabyte in /usr

find /usr -type f -size +1M

Let's find all the files that are exactly 500 kilobytes in the whole system

find / -type f -size 500k

Find and Delete files

To delete all the found files, simply add the delete flag in the command. I would suggest that you find the files you want first without using the delete flag, just in case you do a mistake

When you are ready, simply add the delete flag

find . -type f -size -283c
find . -type f -size -283c -delete