I know I can get disk usage of the files/directories in a directory like this:

for file in $(ls); do du --hum --sum $file; done

That seems to break down if the files/directories have spaces in their names. So I tried this:

find . -maxdepth 1 -type d -print0 | xargs -0 du --hum --sum

That yields only this:

2.3G    .

Whereas there are 8 subdirectories in my directory.


2 Answers 2


You can also just apply the max-depth directive and take out --sum in your du invocation like so:

du --hum --max-depth=1

It will also display directories with spaces.

Here's example output demonstrating that directories with spaces will show up:

4.0K    ./regular_dir1
4.0K    ./regular_dir2
4.0K    ./dir with spaces

Not as good as EWJ00:

find . -maxdepth 1 -type d -print0 | while read -d $'\0' file; do du --hum --sum "$file"; done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.