Link to home
Start Free TrialLog in
Avatar of lolaferrari
lolaferrariFlag for United Kingdom of Great Britain and Northern Ireland

asked on

find the biggest files on /

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
SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you may use the -mount option with find. Try

find / -mount -type f -exec ls -l {} | du -k | sort -rn
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.



Tom
Avatar of lolaferrari

ASKER

many thanks