• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

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
0
lolaferrari
Asked:
lolaferrari
2 Solutions
 
woolmilkporcCommented:
Hi,

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

wmp
0
 
joolsCommented:
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.
0
 
wesly_chenCommented:
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

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

du -sm
  show file size in MB
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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

find / -mount -type f -exec ls -l {} | du -k | sort -rn
0
 
TomuniqueCommented:
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
0
 
lolaferrariAuthor Commented:
many thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now