How to identify the largest files in a directory including in its subdirectories? I have a directory with a lot of files and subdirectories. I know there are a small number of large files contained somewhere within. What is a quick/easy way to identify one or more large files in a directory, including throughout all it's sub directories?
I tried this:
find . -printf '%s %p\n'|sort -nr|head
find: -printf: unknown primary or operator

and this:
find -type f -printf '%s %p\n' |sort -nr | head

find: illegal option -- t
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]

and this:
find . -type f -printf &quot;%s %p\n&quot; | sort -nr | head -1
find: -printf: unknown primary or operator
I like spotlight better than crawling the filesystem for speed reasons. This doesn't directly report sizes so you can sort top 10, but you can quickly (fraction of a second) locate places where large files exist.
mdfind 'kMDItemFSSize &gt; 2000000000' | grep &quot;$(pwd)&quot;

More options are on this thread. Add or remove zeroes or pick your size threshold for finding large files.

As to your syntax errors and other problems you'll face is handling spaces in files and directories, hence the &quot; &quot; around $(pwd) so you can quickly get in territory where you need to learn a bit more about shells, pipes, white space and escaping words / variables. Worst case, isolate each one element above so you can learn what the output of the find command is telling you and they layer back the filters / processing once you have valid results.
If all you are after cleaning large files and you don't need a script and want to learn that later. I recommend system information, storage management or Daisy Disk. Finder also can calculate all sizes well for me in preferences if you want to interact as you navigate.