We may face disk space issues in our production/development/QA systems were multiple applications will be running. So if we need to search for files greater than the particular size. How would we do that? To check manually each and every file size is particularly difficult. Now we will see how to find files bigger or smaller than X size in Linux systems.

Find Files Bigger Or Smaller Than X size

We can use “find” command to find the files bigger or smaller than the given size.

For now, if we need to find files that are bigger than 2GB in a directory, use the below command.

find . -type f -size +2G

Here, the dot(.) says the current directory. To search for files in the entire file system we will use the below command.

 

find / -type f -size +2G

 

If we need to search files in the Downloads folder, we will use the below command.

find Downloads/ -type f -size +2G

To find the files which are smaller than X size, for example, 2GB, we will use the following commands.

find . -type f -size -2G

We can use different formats for the size of the file instead of GB, such as

  • ‘c’ for bytes
  • ‘w’ for two-byte words
  • ‘k’ for kilobytes
  • ‘M’ for Megabytes
  • ‘G’ for Gigabytes

Example of Megabytes ( MB ), to find files greater than 40MB, use the below command,

find . -type f -size +40M

 

To find files between a certain size. If we need to find files between 50MB to 80MB we can use the below command.

find -size +50M -size -80M

 

To find files of the exact size, for example 60MB, use below command.

find -size 60M

For more details, you can refer to man pages.

man find

© 2020, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

0 Comments

Leave a Reply

Keep ahead of COVID-19

Follow the below safety measures as precautionary steps to avoid COVID-19 1. Use face mask in public Places 2. Use Hand sanitizers 3. Maintain Social Distancing 4. Avoid going to crowded places 5. Avoid touching eyes, nose and mouth