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?
To get the total size of a directory in Linux, you can use the du (disk-usage) command.
Display the size of one or more directories, subdirectories, and files by using the du command. Sizes are displayed in 512-byte blocks. Displays the size of each directory that you specify, including each subdirectory beneath it.
How to view the file size of a directory. To view the file size of a directory pass the -s option to the du command followed by the folder. This will print a grand total size for the folder to standard output. Along with the -h option a human readable format is possible.
You can display the size of directories by using the du command and its options. Additionally, you can find the amount of disk space taken up by user accounts on local UFS file systems by using the quot command. For more information about these commands, see du(1M)and quot(1M).
You want the -d
or --max-depth
option.
du -d 2
Limit the depth of search --max-depth=N
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With