Finding large files
In OSX, I can find what’s taking up my disk space using Disk Inventory X or GrandPerspective. That’s all well and good, but today I needed to get similar results over SSH. Observe.
du -k --max-depth=X | sort -r -g | head -n Y
It basically says “from the current directory, list everything at most X deep by kilobytes, sort it in descending order and only show me the top Y results”. With values like X=4 and Y=10, you’re bound to find the behemoths.
Update
Here’s another way of getting the same results, but with the option for further refinement.
find -size +1M -type f -print0 | xargs -0 ls -Ssh1 | head
find -size +1M -exec du -sk {} \; | sort -nr | less