代码改变世界

How to sort directories (folders) by size in Linux

2021-09-22 18:10  DataBases  阅读(23)  评论(0编辑  收藏  举报

du --si --max-depth=1 /home/ | sort -n -r |more

Breakdown:
du = show disk usage
-si = in human readable (aka "nice") numbers
--max-depth=1 only show this and 1 subdirectory deep

the output is then piped to sort in numeric order reversed (i.e. largest first)

the output is then piped to more so you get it page at a time.