ShareIf you're new here, you may want to subscribe to my RSS feed and if you have questions related to your ubuntu system post question to our forums. Thanks for visiting!
{lang: 'en-GB'}
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
Related posts
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
[Reply]
You can do this to:
for i in `du -s * |sort -n |cut -f2`; do du -h $i; done
[Reply]
Also you can try this:
ls -Slh|cut -c32-36,52-
[Reply]
Along the lines of Eli Crffield’s post (but showing everything underneath, instead of just the pwd) how about:
du -ab | sort -n
[Reply]
BTW, I forgot… for those of you who prefer gui interaction, there’s always something like “kfind” and “gnome-find” too. Ah… so many ways to slice the onion!
[Reply]
du -h | sort -n #works fine for me
[Reply]
ls -lSh works for me.
[Reply]
ls -lrSh
Same deal as Travis but larger files sorted to the bottom of the list.
[Reply]
To get a sorted human-readable output of the file size and name you can use:
ls -lSh *.ogg | awk ‘{print $6 “\t” $9}’
[Reply]
faif Reply:
January 3rd, 2012 at 9:20 am
Since the previous solution works only on files (ls reports the default block size for directories), here’s a second (slower) solution that works on mixed (directories and files) lists:
du -s ~/* | sort -rn | awk ‘{print $2}’ | xargs du -sh
[Reply]