How to show the largest files under a directory on Mac OS X (Unix)
By Alvin Alexander. Last updated: December 23 2017
Here’s an example that shows how to find the largest files under a directory on MacOS and Linux/Unix systems.
A du/sort command to show the largest files under a directory on Mac OS X
The Unix/Linux command that worked for me on my MacOS system is this:
$ du -a * | sort -r -n | head -10
du
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. After that, head -10
shows only the first ten lines of output. In the Music folder on my Mac the command and output look like this: