Using Terminal to Find Large Files in a Nested Folder on Mac

When your Mac’s storage is running low, it’s essential to identify and remove large files that are taking up valuable disk space. While you can manually search for large files using Finder, using the Terminal provides a more efficient way to find them, especially in nested folders. In this blog post, we will explore how to utilize the Terminal to find large files on macOS.

To begin, open the Terminal application on your Mac. You can find it in the Utilities folder within the Applications folder. The Terminal allows you to execute commands directly on your computer’s command line interface.

The key command for finding large files is find. Combined with the du command, which displays disk usage, you can efficiently identify large files within nested folders. Here’s the command you can use:

find /path/to/folder -type f -size +100M -exec du -h {} +

Let’s break down what each part of the command does:

  • /path/to/folder: Replace this with the actual path to the folder where you want to search for large files. For example, if you want to search within the Documents folder, the path would be /Users/YourUsername/Documents.
  • -type f: This parameter restricts the search to only files, excluding directories. It ensures that the command focuses solely on finding large files.
  • -size +100M: This option specifies the minimum file size to search for. In the provided example, it’s set to 100 megabytes. Feel free to adjust this value according to your specific requirements.
  • -exec du -h {} +: This portion executes the du command on each file found and displays the disk usage in a human-readable format, providing you with the file size information.

After executing the command, the Terminal will list the large files it finds within the specified folder, including their corresponding sizes. This enables you to identify which files are taking up the most space on your Mac’s storage.

If you are at current folder you can simply type:

find . -type f -size +100M -exec du -h {} +

Here’s an example of the output you might see when using the command to find large files in a nested folder on macOS:

123M    /path/to/folder/large-file1.txt
256M    /path/to/folder/subfolder/large-file2.jpg
175M    /path/to/folder/subfolder/large-file3.mov

By using the Terminal to find large files, you can efficiently manage your storage space and take appropriate actions, such as deleting unnecessary files or moving them to external storage devices.

In conclusion, the Terminal is a powerful tool for finding large files within nested folders on your Mac. By leveraging the find and du commands, you can quickly identify and manage space-consuming files, keeping your Mac organized and optimized.