
In summary, if you wanted to see how to show the largest files under a directory on MacOS, Unix, and Linux systems, I hope this is helpful. Their solution was very close, but just needed a minor change or two to work on MacOS.

Note: I was pointed towards this solution by this page. In that command, head -30 prints the first 30 results, but then the tail command shows only the last 10 files, which displays files 21-30 in the end. To show files 21-30 you can add in the tail command, like this:ĭu -a * | sort -r -n | head -30 | tail -10

To show the first 20 files/directories you’d use this command: Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc. Users/Al/Music> du -a * | sort -r -n | head -10Ĩ049464 iTunes/iTunes Music/Unknown ArtistĦ101880 iTunes/iTunes Music/Unknown Artist/Unknown Album Variations of that `du` commandĪs mentioned, that command shows how to display the largest 10 files and folders under the current OS X directory. Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. In the Music folder on my Mac the command and output look like this: After that, head -10 shows only the first ten lines of output. The Unix/Linux command that worked for me on my MacOS system is this:ĭu is the disk usage command, and the -a flag says, “Display an entry for each file in a file hierarchy.” Then I use the sort command to sort the du output numerically and in reverse. A du/sort command to show the largest files under a directory on Mac OS X Solution: Use the Unix du (disk usage) command, and sort its output. Now, you can click and drag your Home folder and drop it on Finder's sidebar.MacOS FAQ: From the command line, how do I show the largest files under a directory on macOS (and Linux/Unix systems). With your Home folder selected in Finder, hit Command-up arrow to move up one level in Finder. (Oddly, the home folder is called Home in this menu.) You can use the Go pull-down menu from the menu bar to go to the Home folder. To find your Home folder, open Finder and use the keyboard shortcut Command-Shift-H. It lives in the Users folder (along with any guest folders if you created additional user profiles). It features a home icon, but its title is the name you chose for your user account. The first thing you should know about the Home folder is that it's not named Home.


I'll show you how to find your Home folder and add it to Finder's sidebar for quick and easy access. Also, you can go to this folder on Mac using the Finders left. But strangely, the Home folder is hard to find the in Finder by default. In the Finder, you can quickly navigate to your Home folder using the Cmd+Shift+H shortcut. The Home folder on your Mac contains a number of folders - Applications, Desktop, Documents, Downloads, Movies, Music, Pictures, Public - that you'll likely access frequently.
