du only for Directories

As you know, “du” command (du for Disk Usage) can be used to get the list of directories along with other details. But the biggest problem is du would also list all the files along with all the directories and subdirectories inside in it. Suppose if we want to display only the directories then we can use du with some certain modification as shown below

du -sh ./*/

For example when you run the above command it will list only the directories as shown below

du

Incase if you need to sort it by size then you can use the below command

du -sh */ | sort -hr
du

You may also like...