I want to get the size of all directories within a specific directory. I was thinking something like
find . -type d -exec du -sh {} \;
But that returns all directories recursively. How can I limit the depth?
I want to get the size of all directories within a specific directory. I was thinking something like
find . -type d -exec du -sh {} \;
But that returns all directories recursively. How can I limit the depth?
Add
-maxdepth 1
to yourfind
parameters.Why use find at all and not simply glob for directories?
This one should do the job efficiently :
One big difference I think of is that, when encountering hardlinked files, they will be counted only once. In a find loop, they will be counted once per base directory. [Is it correct english?]
You can use the -maxdepth option.
I'm using this one,
basically there are many ways to skin a cat :)
You can also do this:
What it does is to take the subdirectories of the current directory, find its individual's size and in the end, it prints the total size.