Ubuntu Geek

Ubuntu Linux Tutorials,Howtos,Tips & News | Gutsy,Hardy,Intrepid

  • RSS Feed

    subscribe to the ubuntu Geek RSS feed

  • Follow Us on Twitter

  • Sponsor


  • Categories

  • Meta

  • Sponsor

  • Archives

  • Support Ubuntugeek

    Amount $:
    Website(Optional):


  • Favourite Sites

How to Sort files and folders by size

Posted by admin on July 27th, 2007 Email This Post Email This Post

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

If you want to Sort your files and folders by size use the following tip

You need to open terminal use the following command

ls -lS –block-size=1 | awk ‘ {print $5,$6,$7,$8}’ >size.txt; du -s –block-size=1 */ >>size.txt; sort -n size.txt

or

{ ls -lS –block-size=1 | awk ‘ {print $5,$6,$7,$8}’; du -s –block-size=1 */ ; } | sort -nr | less

Share/Save/Bookmark

Related Articles

3 Responses to “How to Sort files and folders by size”

  1. Eli Criffield Says:

    This is i think the first thing someone showed me my first day on the job as a unix admin may years ago.

    $ du -s * |sort -n

    with gnu du you can add -m to get the output in megs. ( du -sh * is nice too but won’t sort)

    $ du -sm * |sort -n

    Many Many hours of a Unix admins life is spent doing du -s * |sort -n then cd to the last directory and repeat ….

    If your looking for what filled up your filesystem that wasn’t full an hour ago you can also whip together a big find command to find all files over say 100 megs that where modified in the last hour.

    Eli Criffield

  2. ahvargas Says:

    You can do this to:
    for i in `du -s * |sort -n |cut -f2`; do du -h $i; done

  3. ahvargas Says:

    Also you can try this:
    ls -Slh|cut -c32-36,52-

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>