Linux 命令行: du ——-如何使其仅显示每个目录的 total

我是这样做的(使用 coreutils _ 8.5-1ubuntu6 _ amd64) :

du -sch `find ./ -maxdepth 1 -type d`

我正在寻找一个简单的方法(较短的 cmd)找到 子目录的大小。谢谢。

112891 次浏览

On my version of du (from coreutils 8.14) this works:

du -h -d 1

-h is for human readable sizes.

create an alias:

alias subs="du -sch `find ./ -maxdepth 1 -type d`"

and I thing 'subs' is much shorter.

This works with coreutils 5.97:

du -cksh *

not sure about coreutils, but I like df -h <directory> or df -h. The -h is for human readable.

The following did the job for me:

du -hs */

Without the trailing slash the output was not restricted to directories.

actually you can try :

du -kh | cut -f1

This command is your answer:

du -sh *

All these answers didn't work for me, I think some parameters depend on the environment.

So I did this:

du -csh /home/pi/walala/* | grep total | sed 's/ *\stotal* *\(.*\)/\1/'

OR for bytes

du -csb /home/pi/walala/* | grep total | sed 's/ *\stotal* *\(.*\)/\1/'