linux 命令行:du --- 如何让它只显示每个目录的总数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10103604/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:42:50  来源:igfitidea点击:

linux command line: du --- how to make it show only total for each directories

linuxcommand-line

提问by Andrew_1510

I am doing it by (with coreutils_8.5-1ubuntu6_amd64):

我这样做(使用coreutils_8.5-1ubuntu6_amd64):

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

I am looking for a simple way (shorter cmd) to find size of subdirectories. Thank you.

我正在寻找一种简单的方法(更短的 cmd)来查找子目录的大小。谢谢你。

采纳答案by DanS

This works with coreutils 5.97:

这适用于 coreutils 5.97:

du -cksh *

du -cksh *

回答by Albert Veli

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

在我的 du 版本(来自 coreutils 8.14)上,这有效:

du -h -d 1

-h is for human readable sizes.

-h 用于人类可读的大小。

回答by shem

create an alias:

创建别名:

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

and I thing 'subs' is much shorter.

我认为“潜艇”要短得多。

回答by Erin

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

不确定 coreutils,但我喜欢df -h <directory>df -h。-h 用于人类可读。

回答by Silicomancer

The following did the job for me:

以下为我完成了这项工作:

du -hs */

du -hs */

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

没有尾部斜杠,输出不限于目录。

回答by AkaKaras

actually you can try :

其实你可以试试:

du -kh | cut -f1

回答by babak khaksari

Hi I Think This Command Is Your Answer

嗨,我认为这个命令是你的答案

du -sh *

杜 -sh *