find all files of a particular size

From WebHostingNeeds.com
Jump to: navigation, search

find command can be used to find all the files of a particular size. Lets find all files of 1025 byes on your server.

find / -type f -size 1024c -exec ls {} \;

File size can be specified in

  • b - for 512-byte blocks (this is the default if no suffix is used)
  • c - for bytes
  • w - for two-byte words
  • k - for Kilobytes (units of 1024 bytes)
  • M - for Megabytes (units of 1048576 bytes)
  • G - for Gigabytes (units of 1073741824 bytes)

You can search for exact file size, or just for bigger (+) or smaller (-) files.

For example all bigger than 1024k files would be found with something like:

find / -type f -size +1024k -exec ls -lh {} \;

For finding files smaller than 1024 KB use

find / -type f -size -1024k -exec ls -lh {} \;