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

LinuxCommand Line

Linux Problem Overview


I am doing it by (with 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.

Linux Solutions


Solution 1 - Linux

This works with coreutils 5.97:

du -cksh *

Solution 2 - Linux

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

du -h -d 1

-h is for human readable sizes.

Solution 3 - Linux

The following did the job for me:

du -hs */

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

Solution 4 - Linux

Hi I Think This Command Is Your Answer

du -sh *

Solution 5 - Linux

actually you can try :

du -kh | cut -f1

Solution 6 - Linux

create an alias:

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

and I thing 'subs' is much shorter.

Solution 7 - Linux

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

Solution 8 - Linux

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/'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndrew_1510View Question on Stackoverflow
Solution 1 - LinuxDanSView Answer on Stackoverflow
Solution 2 - LinuxAlbert VeliView Answer on Stackoverflow
Solution 3 - LinuxSilicomancerView Answer on Stackoverflow
Solution 4 - Linuxbabak khaksariView Answer on Stackoverflow
Solution 5 - LinuxAkaKarasView Answer on Stackoverflow
Solution 6 - LinuxshemView Answer on Stackoverflow
Solution 7 - LinuxErinView Answer on Stackoverflow
Solution 8 - LinuxZorroView Answer on Stackoverflow