/kernel_reloaded/

Author:

Other contacts

Novi članci

Flickr Goodness

Categories

July 24, 2012 @ 22:35

cli oneliner – sort top 10 directories

 
One simple oneliner that I picked up few years ago, and it is great for finding directories that eat up most of space in current directory.
 
ls -A | grep -v -e '^\.\.$' |xargs -i du -ks {} |sort -rn |head -11 | awk '{print $2}' | xargs -i du -hs {}
 

Filed under linux, tips&tricks

5 Comments »

  1. Posted by Tobias Florek

    July 24, 2012 @ 23:28

    what about

    du –max-depth 1 -h .|sort -rh|head -12

    it should perform quite better…

  2. Posted by Doug

    July 25, 2012 @ 3:40

    You can shorten that a bit on systems where sort supports ‘-h’

    ls -A | grep -v -e ‘^\.\.$’ |xargs -i du -hs {} |sort -hr |head -11

  3. Posted by foobar

    August 26, 2012 @ 3:20

    New versions of du and sort have ‘human’ so now all you need is:

    $ du -hxs ./* | sort -hr

  4. Posted by Igor Pozgaj

    September 7, 2012 @ 9:32

    The second command in the pipeline (excluding .. with grep) is superfluous as ls -A won’t include . and .. in files/directories listing (read the manpage).

  5. Posted by Valent Turkovic

    April 24, 2014 @ 9:14

    Thanks! For OpenWrt I used this and it helped me a lot, just a bit edited:

    du -d 1 |sort -nr

RSS feed for comments on this post · TrackBack URI

Leave a Comment

    Archives

    Flickr photostream

    _IGP5438
    Gem
    Gambela Microfleece Full Zip Jacket by TRIMARK (Women\'s)
    今日のだまし絵 ( その3)20140822
    Poppies, Morgan Trailhead, Santa Ana Mountains, Cleveland National Forest
    _MG_5476
    #tbt Me & My Sis @jazzyjoyce
    P1080019.jpg
    IMG_8747

    Meta meta :)