Operating System - HP-UX
1819682 Members
3783 Online
109605 Solutions
New Discussion юеВ

Finding files larger than 200 MB

 
SOLVED
Go to solution
Garrin Thompson
Advisor

Finding files larger than 200 MB

Does anyone know how I might go about finding all files in a directory larger than a specified size. We're doing an audit on our production directories and some management want a report listing all files larger than 200 MB and what their size is. Being a new Unix Admin, I just don't know how I might go about this task in the most efficient way.
2 Years old on HP-UX 10.20 R9000 server
7 REPLIES 7
Kofi ARTHIABAH
Honored Contributor

Re: Finding files larger than 200 MB

Try the following:

# find / -size +200000000c -print
to list the file paths or:

# find / -size +200000000c -exec ls -l {} \;

cheers
nothing wrong with me that a few lines of code cannot fix!
Rita C Workman
Honored Contributor

Re: Finding files larger than 200 MB

Yes you can do a find...
find / -size +100000 -print

Note that the above looks for block size (so 2000 blk*512 byte=1mb) the above if I did the math right would be for 50mb; but you may want to check..
If you want to key by mb than:

find /file_sys -size +50000000c -print

For auditing purposes you could send the output to a file by changing -print to >output.file

Regards,
Garrin Thompson
Advisor

Re: Finding files larger than 200 MB

Man...

You all are quick and awesome! Thanks for the help. Keep all the new fresh ideas coming, too, because it makes for some quick and easy HP-UX Admin training for me.

My Hat's off to ya'll!
2 Years old on HP-UX 10.20 R9000 server
Anthony deRito
Respected Contributor

Re: Finding files larger than 200 MB

You can use the command:

find $DIR -xdev -size +$VARc -exec ll -lt {} ;

where:
$DIR is the directory to start search
$VAR is the size to declare.

Tony
Bill Hassell
Honored Contributor
Solution

Re: Finding files larger than 200 MB

If the reason management is looking for large files is to address disk space issues, perhaps it is a better idea to find the biggest directories first. After all, a runaway script or program could create a directory with 50,000 files, all just 10 Kbytes in size (no big files). Yet the directory takes up 500 megs of space.

The secret is du, or more specifically, du -kx /starting_point. Since this will just traverse the directories in no particular order, use sort to arrange the sizes as in:

du -kx /start_point | sort -rn

You may want to pipe the output into a file or email message. Run this command on each mountpoint.


Bill Hassell, sysadmin
Jennifer Chiarelli
Regular Advisor

Re: Finding files larger than 200 MB

With HP-UX ver 11, you can use SAM. Run Sam, Routine Tasks, Selective File Removal.
It's a binary world!
John Palmer
Honored Contributor

Re: Finding files larger than 200 MB

Don't forget that 200Mb is actually 209715200 bytes or 409600 512 byte blocks.

Regards,

John