Searching based on file size

Based on the file sizes of the files, a search can be performed:

# Files having size greater than 2 kilobytes
$ find . -type f -size +2k

# Files having size less than 2 kilobytes
$ find . -type f -size -2k

# Files having size 2 kilobytes
$ find . -type f -size 2k

Instead of k, we can use these different size units:

  • b: 512 byte blocks
  • c: Bytes
  • w: Two-byte words
  • k: Kilobytes (1,024 bytes)
  • M: Megabytes (1,024 kilobytes)
  • G: Gigabytes (1,024 megabytes)