Show biggest files/directories, biggest first with 'k,m,g' eyecandy

du --max-depth=1 | sort -r -n | awk '{split("k m g",v); s=1; while($1>1024){$1/=1024; s++} print int($1)" "v[s]"\t"$2}'
I use this on debian testing, works like the other sorted du variants, but i like small numbers and suffixes :)
Sample Output
[user@host]> bigfiles
123 m   .
47 m    ./media
27 m    ./.mozilla
21 m    ./src
14 m    ./downloads
1 m     ./.openoffice.org
1 m     ./uni
288 k   ./.gstreamer-0.10
208 k   ./sketchbook
128 k   ./.config
124 k   ./.ipython
56 k    ./.fontconfig
32 k    ./.pal

16
By: hans
2009-02-24 11:03:08

These Might Interest You

What Others Think

Some du versions have a -h option that gives you suffixes.
fastolfe · 486 weeks and 1 day ago
Yeah, but then you cannot get stuff sorted correctly, afaik.
unixmonkey1790 · 486 weeks and 1 day ago
I always do that!!! but in an ugly way (and y sort with -t...) so thanks a lot!! Now, you've a thanks in my .bashrc ;}
lhb · 486 weeks and 1 day ago
Cool :) I like this. I keep my config files in a git repo to sync stuff i hack between different machines, but this is so useful for others.
hans · 486 weeks 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: