Finding Files by Size

Problem

You want to do a little housecleaning, and to get the most out of your effort you are going to start by finding your largest files and deciding if you need to keep them around. But how do you find your largest files?

Solution

Use the -size predicate in the find command to select files above, below, or exactly a certain size. For example:

find . -size +3000k -print

Discussion

Like the numeric argument to -mtime, the -size predicate’s numeric argument can be preceded by a minus sign, plus sign, or no sign at all to indicate less than, greater than, or exactly equal to the numeric argument. So we’ve indicated, in our example, that we’re looking for files that are greater than the size indicated.

The size indicated includes a unit of k for kilobytes. If you use c for the unit, that means just bytes (or characters). If you use b, or don’t put any unit, that indicates a size in blocks. (The block is a 512-byte block, historically a common unit in Unix systems.) So we’re looking for files that are greater than 3 MB in size.

See Also

  • man find

  • man du

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.25.41