macOS FAQ: From the command line, how do I show the largest files under a directory on macOS (and Linux/Unix systems).
Solution: Use the Unix du
(disk usage) command, and sort its output.
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: