用 du 与 sort 找出最大文件
按大小排序文件与目录,支持人类可读单位。
运行 du -ah . | sort -rh | head -20,列出最大的二十项。
01命令
命令
$ du -ah . | sort -rh | head -2002作用说明
du 输出每个文件和目录的大小,sort -h 正确处理人类可读单位,head 截断列表,立刻得到空间审计。这种可组合的管道正是用 shell 分析文件系统的典型理由。
03风险
!注意: 遍历超大目录树耗时且可能跨挂载点;加 -x 可限制在单一文件系统。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- du.1.en.html manual page (Debian bookworm)依据: Documents du -a and -h for per-file sizes.
- sort.1.en.html manual page (Debian bookworm)依据: Documents sort -h for human-readable numeric sorting.
最后验证: 2026-10-13 · 分类: 文件与文件夹