lolaferrari
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you may use the -mount option with find. Try
find / -mount -type f -exec ls -l {} | du -k | sort -rn
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.rp m
Use the |awk '{print $11}' (or some variant) to get just the filenames listed.
Tom
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
Use the |awk '{print $11}' (or some variant) to get just the filenames listed.
Tom
ASKER
many thanks
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.