linux command line: du --- how to make it show only total for each directories
LinuxCommand LineLinux 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/'