find the biggest files on /

Posted on 2011-10-07
Medium Priority
Last Modified: 2012-05-12
i want to find the biggest files under / but there is a separate filesystem for /var /opt /opt/tmp but i don't want to include these in the search.
i normally run find <from where> - type f -exec ls -ls {} \; | sort .....
i would like a command that will work on solaris and on linux and also aix and hpux if possible
Question by:lolaferrari
LVL 68

Assisted Solution

woolmilkporc earned 1000 total points
ID: 36934159

use the "-xdev" flag of find.
It keeps find from traversing filesystems and should work on all mentioned Unixes.

LVL 19

Expert Comment

ID: 36934208
As pointed out by wmp, -xdev will look in the current filesystem only, it is the same as using the  -mount option  which you may have used on other *nix's, I cant remember if -xdev is interchangeable.

On HPUX there used to be a script called bigfiles which did the same thing, though that was on HPUX 8.02 so it might have changed a bit since then.
LVL 38

Accepted Solution

wesly_chen earned 1000 total points
ID: 36934282
To make list shorter, if you know the biggest file are over 1GB, then

find / -xdev -type f -size +1G  -exec du -xsm {} \; | sort -n

-size +100M
  to list files greater than 100MB

du -sm
  show file size in MB
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 40

Expert Comment

ID: 36934960
you may use the -mount option with find. Try

find / -mount -type f -exec ls -l {} | du -k | sort -rn

Expert Comment

ID: 36938950
wasn't aware du used stdin.  think there's an xargs missing somewhere...

why not just sort the output of find?
This should work on any FS, using -xdev as WMP pointed out.

** find {fsname}  -xdev -size +{lowersize limit} -ls  |sort -nk7  |tail -{#files to view}

You mentioned you'd like it to work on AIX as well, and AIX doesn't support some of the linux added options.
So, bringing it down ot the lowest common denominator, use the size with the "c" suffix, which is in bytes.

Sense you're passing it to sort, the -size parm is really only there for performance, so find will quickly filter out the small stuff, and the "ls parm" and the sort command only have to work on the stuff that has a chance of mattering.  on a relatively small fs (like / should be), it's not required.

find / -xdev -ls |sort -nk7 |tail -1    (show me the largest file in / fs )  

102415 48008 -rw-r--r--   1 root     root     49106245 May 18  2007 /root/INSTALLED/java-1_5_0-ibm-1.5.0_sr3-13.rpm

Use the |awk '{print $11}'   (or some variant) to get just the filenames listed.


Author Closing Comment

ID: 37033072
many thanks

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month15 days, left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question