The Size Filter
When your Ubuntu Linux server runs out of disk space, finding the culprit often requires searching for exceptionally large files. While you can use find -size +1G to locate every file larger than 1 Gigabyte, sometimes you need to isolate files that fall into a very specific size bracket. For example, if you are looking for corrupted log files that you know are exactly between 50 Megabytes and 100 Megabytes, returning a list of every massive 500MB database dump or tiny 2KB text file will make your search results completely unreadable. You must explicitly bound the search engine using a size range.
Using the find Command with Multiple Size Flags
The Linux find command allows you to chain multiple -size flags together to create a strict mathematical boundary.
- Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
- To scan the entire
/var/log/directory and return every file that is larger than 50 Megabytes but smaller than 100 Megabytes, type the following command exactly: sudo find /var/log/ -type f -size +50M -size -100M- Press Enter and provide your administrator password.
Creating the Boundary
Prefixing the command with sudo is mandatory to read system log directories. The syntax utilizes the plus (+) and minus (-) operators. Because the find command evaluates conditions with an implicit logical AND, typing -size +50M -size -100M forces the engine to only print files that meet both conditions simultaneously. You can use k for Kilobytes, M for Megabytes, and G for Gigabytes. This targeted approach guarantees that you can surgically extract a list of files that perfectly match the exact profile of the data you are hunting, ignoring everything else on the hard drive.