How to search by file size?

To search for files by size using the find command, you can use the -size option. This option allows you to specify the size of the files you want to find.

Syntax:

find [path] -size [size][unit]

Size Units:

  • c - bytes
  • k - kilobytes (1K = 1024 bytes)
  • M - megabytes (1M = 1024K)
  • G - gigabytes (1G = 1024M)

Examples:

  1. Find files larger than 1 megabyte:

    find . -size +1M
  2. Find files smaller than 100 kilobytes:

    find . -size -100k
  3. Find files exactly 500 bytes:

    find . -size 500c
  4. Find files between 1 and 10 megabytes:

    find . -size +1M -a -size -10M

These commands will help you locate files based on their size in the specified directory and its subdirectories.

0 Comments

no data
Be the first to share your comment!