How to find all folders that are larger than 1GB or 10GB on the Mac HD?
Solution 1:
find
doesn't auto-sum so it only looks at the size of each individual item (which in this case would be the directory entry itself). You could do something like
du -h / | grep -E '^[0-9 .]+[GTP]\t'
Solution 2:
I did some research and it seemed one flexible way is:
du -sk */ | awk '$1 > 1048576 { print $2 }' # larger than 1GB
Note that the original source answer is on Unix Stack Exchange, and the line was
du -sk * | awk '$1 > 10485760 { print $2 }' # larger than 10GB
and the */
in the first command above is to choose only the directory instead of both files and directories.
I haven't used awk for a while, but the first command above can be used to find all directories that is larger than 10GB (or 20GB, or 50GB), with the size in GB in front, as follows. Just change the size 10
in the command for a different size:
du -sk */ | awk '$1 > (1000 * 1000 * 10) { printf "%.2f %s\n", $1 / 1000 / 1000, $2 }'
and it can be tweaked for whether it is GB
vs GiB
accordingly.