[英]linux command line: du --- how to make it show only total for each directories
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 .我正在寻找一种简单的方法(较短的 cmd)来查找子目录的大小。 Thank you.
谢谢你。
This works with coreutils 5.97:这适用于 coreutils 5.97:
du -cksh *
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 用于人类可读的大小。
The following did the job for me:以下为我完成了工作:
du -hs */
Without the trailing slash the output was not restricted to directories.没有尾部斜杠,output 不限于目录。
This command is your answer:这个命令就是你的答案:
du -sh *
actually you can try:其实你可以试试:
du -kh | cut -f1
create an alias:创建别名:
alias subs="du -sch `find ./ -maxdepth 1 -type d`"
and I thing 'subs' is much shorter.我认为“潜艇”要短得多。
not sure about coreutils, but I like df -h <directory>
or df -h
.不确定 coreutils,但我喜欢
df -h <directory>
或df -h
。 The -h is for human readable. -h 用于人类可读。
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/'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.