Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Find all large files on a Linux machine (See related posts)

Finds all files over 20,000KB (roughly 20MB) in size and presents their names and size in a human readable format:

find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' 

Comments on this post

zoestardust posts on Feb 26, 2008 at 23:06
This does not show names or locations, it just lists a bunch of file sizes
syncshaker posts on Apr 08, 2008 at 05:25
You can customize this command by changing e.g. / by . or any directory path, or - and zoestardust you're right to point it out - by replacing in awk $9 by likely $8. Anyway the command is globally right ;) ( a typo ? )
webshowpro posts on Jul 22, 2008 at 10:56
It does work as shown on older versions of RedHat, and likely others. The output of awk seems to have changed a bit over the years and on Ubuntu (probably all Debian) based system the above command will only show a list of file sizes. As syncshaker pointed out on Ubuntu systems change the $9 to a $8 and it will work:

find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts