Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list directory size of all child directories? [closed]

Tags:

linux

bash

shell

From the shell, I need to list the size of all child directories. I am currently using:

du -hs * | sort -hr 

However, this only gets one level down and does not traverse the directory tree.

like image 308
Eli Reiman Avatar asked Jan 04 '19 15:01

Eli Reiman


1 Answers

The simplest is:

du -h --max-depth=1 parent

This will show all sizes of the children of parent If you also want the grandchildren, you can do

du -h --max-depth=2 parent

If you want the whole family

du -h parent

All these will just summarize the total directory size of each subdirectory up to a given level (except the last, it will give for all)

If you don't want the content of the subdirectories, add the -S flag.

like image 56
kvantour Avatar answered Oct 13 '22 19:10

kvantour