Linux get the size of a folder and its subfolders to a certain depth

user1984646 picture user1984646 · Feb 6, 2013 · Viewed 30.9k times · Source

In Linux, I have the following folder structure, I want to get the size of the folder and its subfolders to a certain depth.

I have this structure:

/AAAA/BBBB/1111
/AAAA/BBBB/2222
/AAAA/BBBB
/AAAA/CCCC
/AAAA/DDDD/3333
/AAAA/DDDD
/AAAA

du -m, shows me the entire tree, not just 2 levels as I need. What is the proper command?

Answer

Xymostech picture Xymostech · Feb 6, 2013

You want the -d or --max-depth option.

du -d 2