Linux 'find' command can find files of a certain file size. Here's some examples.

September 17, 2009


 

Learn how to find files in Linux based on their file size with these Linux find command examples.

In Linux, you can find files of a certain size from the command line using the 'find' command. If you don't know the exact size of the file you want to find, which you often won't, you can also use the 'find' command to find files which are larger than or smaller than a certain size.

Linux 'find' files of a certain size examples

Find files with a size greater than a specified size

Example, let's say you want to find all files with a size greater than 96180 bytes under the current directory. To achieve this, you would run the 'find' command like this:

  1. find * -size +96180c

Find files with a size less than a specified size

And if you'd like to find files less than 96180 bytes, then you'd modify the previous command like so, changing the '+' sign to a '-' sign:

  1. find * -size -96180c

Find files specifying size in bytes, kilobytes, megabytes, or gigabytes

Whereas the previous commands found files based on their size in bytes, you could also find files based on their size in Kilobytes, Megabytes, or Gigabytes. I'm not sure if the 'find' command has an option to specify the size of a file in terabytes, but if you can't find a file that's over a terabyte in size - you must have a pretty big hard drive.

Ok, so let's take the above 'find' command example and modify it so that we're searching for files based on their size in Kilobytes.

The following command will fild all files recursively from the current directory that have a file size greater than 96 Kilobytes:

  1. find * -size +96k

List of available size suffixes that can be used with the Linux 'find' command

All of the suffixes which you can use to specify what unit of measurement the 'file' command should use such as Kilobytes, Megabytes, or Gigabytes and so forth are as follows:

  • the k suffix represents Kilobytes
  • the M suffix represents Megabytes
  • the G suffix represents Gigabytes
  • the w suffix represents two-byte words
  • the c suffix represents bytes
  • the b suffix, which is the default suffix used when no suffix is given, represents 512-byte blocks.

One more example

This example of the 'find' command will find all files that are larger than 1 Gigabyte:

  1. find * -size +1G

Now you can find files by size on your Linux system using the 'find' command to specify the size of the files which you'd like to find. Good luck finding the files you're looking for.


No comments

Add comment

* - required field

*

CAPTCHA image for SPAM prevention
If you can't read the word, click here.
*
*
 

Netdip.com is an excellent web site that's powered by TYPO3 and other great open source software. Netdip.com is also a fat free alternative to ice cream.