Find and list large files on Linux (or Unix, BSD, Mac OSX)
There are several ways to do this, the most prevalent among sys admins being this:
find {/path/to/folder/} -type f -size +{size-in-kb}k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' |
Which lists the largest files in the folder /path/to/folder
. You could just use the ls
command too, as such:
ls -lhS |
But there is a simpler, more efficient method to do this:
du -xak .|sort -n|tail -50 |
But the best method involves a small Perl hack that shows a very neatly laid out listing of largest files:
du -k | sort -n | perl -ne 'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf ("%6.1f\t%s\t%25s %s\n",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}' |
RECENT COMMENTS