for dir in $(ls); do du -sk ${dir}; done

do a directory disk usage summary without giving the details for the subdirectories

Sometimes you want to know the summary of the sizes of directories without seeing the details in their subdirectories. Especially if it is going to just scroll off the screen. This one liner summarizes the disk usage of any number of directories in a directory without giving all the details of whats happening underneath.
Sample Output
dir1 500
dir2 145
dir3 340400
dir4 2345

-15
2009-03-24 13:42:55

These Might Interest You

What Others Think

No need for $(ls) for dir in *; do du -sk $dir; done
atoponce · 478 weeks and 2 days ago
du --max-depth=1
juddmaltin · 478 weeks and 2 days ago
My above method does not fail on names with spaces or other special characters.
juddmaltin · 478 weeks and 2 days ago
Or just do du -sk *
flooey · 478 weeks and 2 days ago
Or for human readable: du -sh * And for just a summary of the current dir: du -sh .
bshep · 478 weeks and 2 days ago
Thanks. I completely missed the max depth argument.
morlockhq_ · 477 weeks and 6 days ago
Thanks for this. I was just building up on something like find . -maxdepth 1 -type d | xargs du -sh but du --max-depth=1 -h just does the job!
udog · 420 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: