Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find command

Status
Not open for further replies.

tty0

Programmer
Nov 13, 2002
108
GB
Hi all,
im new to linux and i have a bit of a problem with one of the servers we have for websites. I understand that the server logs access and transfer are made by the web user account. However during the past 12 months the web account file usage has gone through the roof.

So my pronblem is that i need to search for all files greater than a certain size lets say 5Mb with web as the user. I have managed to dump the output of a search for files on the web user account but the list is exhaustive.

could anyone point me in the right directtion to dump another list for only files greater than a certain size please?

Thanks very much
chris

'mi casa es su casa'
]-=tty0=-[
 
This will work for you.

Code:
#!/usr/bin/perl

use strict;
use File::Find;

my %size;
find(
    sub {
        $size{$File::Find::name} = -s if -f;
    },
    @ARGV
);
my @sorted = sort { $size{$b} <=> $size{$a} } keys %size;
splice @sorted, 20 if @sorted > 20;
foreach (@sorted) {
    printf "%10d %s\n", $size{$_}, $_;
}

 
Try this...
Code:
find /start/dir -type f -user web -size +5000000c -print
This will list all files owned by the user "web" that are over 5 million bytes.

Another way to find your largest files is this...
Code:
du -ok | sort -rn | head -30
This will give you the top 30 directories and how much disk space is taken by the files in it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top