Wednesday 3 April 2019

linux - Display each sub-directory size in a list format using one line command in Bash?


I want to get a list of the directories and their sizes in a list format like how you get when you do a ls -l.


The thing is that is there a one line command that can do this? I see others have long commands just to output this. That's just too long.


What command can do this or combination of commands that can be easily typed? du -h gives it, but it displays all of the sub-folders which is not what I want. just the current directories folders.



Answer



You probably want to see the directories ordered by size:


$ du -hs * | sort -hr


856M    lib
746M share
612M lib64
312M src
267M java
239M bin
179M sbin
173M local
93M i686-w64-mingw32
72M libexec
26M include
20M puppet
772K X11R6
20K man
4.0K games
4.0K etc
0 tmp

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...