Find Files by Size in Mac Terminal

Finding large files on your Mac can help you free up disk space and manage your storage more efficiently. The Mac Terminal provides a powerful way to search for files based on their size using the find command.

In this guide, we will show you how to use Terminal commands to find files by size, making it easier to identify and manage large files in your system.

Using the find Command to Search for Files by Size

The find command allows you to search for files based on various criteria, including size. The basic syntax for finding files by size is:

find /path/to/directory -size +[size][unit]

In this command:

  • /path/to/directory: The directory you want to search in (e.g., ~/Documents).
  • +size: Finds files larger than the specified size.
  • [unit]: Specifies the unit of measurement (e.g., k for kilobytes, M for megabytes, G for gigabytes).

For example, to find all files larger than 100 MB in your Downloads folder, use the following command:

find ~/Downloads -size +100M

This command will list all files larger than 100 megabytes in the Downloads folder.

Using the find Command to Search for Files by Size in Mac Terminal

Finding Files Larger than 1 GB

If you want to search for files larger than 1 GB across your entire system, you can use this command:

sudo find / -size +1G

The sudo command is used here to ensure that you have the necessary permissions to search through system directories. You may be prompted to enter your password.

Finding Files Smaller than a Certain Size

You can also find files that are smaller than a specified size by using the -size option with a minus sign (-). For example, to find all files smaller than 1 KB in your Downloads folder, use this command:

find ~/Downloads -size -1k

This will list all files in the Downloads folder that are smaller than 1 kilobytes.

Finding Files Smaller than a Certain Size in Mac Terminal

Finding Files within a Specific Size Range

To find files that fall within a specific size range, you can combine the find command with multiple -size options. For example, to find files between 100 MB and 500 MB in your Pictures folder, use the following command:

find ~/Pictures -size +50k -size -70k

This command will display all files in the Pictures folder that are larger than 50 KB and smaller than 70 KB.

Finding Files within a Specific Size Range in Mac Terminal

Sorting Files by Size

To make it easier to identify the largest files, you can sort the results by size using the ls command in combination with find. For example, to find and sort files larger than 1 GB in the Documents folder, use this command:

find ~/Documents -size +1G -exec ls -lh {} \; | sort -k 5 -rh

This command will display the files in a human-readable format and sort them by size in descending order (largest to smallest).