find . -type f
gives us a list of file, recursively, starting from here (.)
-print0 | xargs -0 du -h
separate the names of files with NULL characters, so we're not confused by spaces
then xargs run the du command to find their size (in human-readable form -- 64M not 64123456)
| sort -hr
use sort to arrange the list in size order. sort -h knows that 1M is bigger than 9K
| head -20
finally only select the top twenty out of the list
64M ./icons/gnome/icon-theme.cache 23M ./fonts/extra-fonts/arialuni.ttf 22M ./libpinyin/data/bigram.db 21M ./fonts/cjkuni-uming/uming.ttc 20M ./anthy/anthy.dic 18M ./mythes/th_en_US_v2.dat 17M ./fonts/wqy-zenhei/wqy-zenhei.ttc 14M ./icons/hicolor/icon-theme.cache 14M ./icons/Faenza/icon-theme.cache 8.3M ./cracklib/pw_dict.pwd 6.2M ./mm-common/doctags/libstdc++.tag 6.2M ./libhangul/hanja/hanja.txt 5.4M ./icons/Mist/icon-theme.cache 4.8M ./gir-1.0/Gtk-3.0.gir 4.8M ./dict/linux.words 4.4M ./gir-1.0/Gtk-2.0.gir 4.3M ./anthy/zipcode.t 4.0M ./fonts/un-core/UnDotumBold.ttf 3.9M ./opencc/simp_to_trad_phrases.ocd 3.8M ./tor/geoip
from my bashrc ;)
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.
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.
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
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: