Home » Questions » Computers [ Ask a new question ]

Find out which are the bigger files / dir

Find out which are the bigger files / dir

I have a directory from which i want to delete some stuff.

Asked by: Guest | Views: 237
Total answers/comments: 5
Guest [Entry]

"du -k | sort -n | tail

But this belongs on SU, not StackOverflow"
Guest [Entry]

"if you want to see ""heavier"" files, for which i assume they are bigger size files..

du -ch /home |sort -nr|head"
Guest [Entry]

"This rather lengthy function will display a sorted list with human-readable sizes:

dus () { du -bh ${1:+$1/}* |
awk 'BEGIN {KMG=""KMG""}
{printf ""%s %08.2f %s\t%s\n"",
index(KMG,substr($1,length($1))),
substr($1,0,length($1)-1),
substr($1,length($1)),$0}' |
sort -r |
cut -f 2-
}

which you can then pipe through head:

dus | head

It accepts a directory as an argument:

dus /usr/local"
Guest [Entry]

"Typically I will use du -s * | sort -nr for this, and work my way down into the directories with larger sizes. The -s option makes it display the total for each item instead of recursing.

eg:

bcl@fozzy:~$ du -s * | sort -nr
171900 wiki
169932 bb.mail.tar.bz2
112772 tmp
44416 d.mail.tar.bz2
4148 src
2012 public_html
880 Mail
144 sha-search
72 logs
20 tt.txt
16 Maildir
16 brianlane_html
12 Temporary Items
12 Network Trash Folder
8 calendar_html
4 wiki_html
4 procmail.bcl
4 id_rsa.pub
4 foo.sh
4 fetchmail.bcl
4 bb.procmailrc
0 time.out"
Guest [Entry]

Personally I find kdirstat to be very useful to figure out where my disk space has gone. It sorts everything by size, and shows a somewhat useful visual 'treemap' that lets you roughly gauge by sight where space is being used.