#!/opt/perl/bin/perl ############################################################################# # File Name : bigs # Date : 05/20/03 # Author : KME # Description : Find big files in a filesystem # Thread : http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=836546 # Author : A. Clay Stephenson # Thread : How to find the greatest size file in certain mount point? # Change : ############################################################################# use strict; use English; use File::Find; use constant TRUE => 1; use constant REGULAR_FILE => 0100000; # 1.0 02/26/2004 acs my ($cc,$Largest_Size,$BigFile) = (0,-1,''); sub process { use integer; my ($mode,$size) = (stat($File::Find::name)) [2,7]; my $filetype = ($mode & 0170000); if ($filetype == REGULAR_FILE) { if ($size > $Largest_Size) { $BigFile = $File::Find::name; $Largest_Size = $size; } } } # process #@ARGV = qw(.) unless @ARGV; if( $#ARGV != 0) { print STDERR "Usage: $0 Filesystem\n"; print STDERR "\n"; exit 1; } my $file_system = $ARGV[0]; my $size_mb = 0; $cc = find({wanted => \&process,no_chdir => TRUE},$file_system); if ($Largest_Size >= 0) { $size_mb = ($Largest_Size / 1024 / 1024 ); printf("%s\t%d (Bytes) %d (MB)\n",$BigFile,$Largest_Size,$size_mb); } exit($cc); __END__