find the biggest files on /

Posted on 2011-10-07
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


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

    LVL 19

    Expert Comment

    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

    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
    LVL 40

    Expert Comment

    you may use the -mount option with find. Try

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

    Expert Comment

    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

    many thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. Please see for the updated article. It is avail…
    Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
    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…
    Video by: Phil
    This video goes over how to configure and start a jail in FreeBSD.  This video is meant to supplement the article included with this course.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now