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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question::how to check symbolic link, group by user etc

Status
Not open for further replies.

slok

Programmer
Jul 2, 1999
108
SG
currently the code I have below returns me or print out
in sorted order the largest file size and their path.

I need help to change it to
1. find the file size of regular files as well as size of
symbolic links

2. return in sorted order the disk usage and their respective users

thanks

================

my %size;
my @sorted;

find (sub {
$size{$File::Find::name} = -s if -f; }, @paths
);

@sorted = sort {$size{$b} <=> $size{$a}} keys %size;
splice @sorted, 20 if @sorted > 20;
foreach (@sorted) {
printf (&quot;Hello %10d %s\n&quot;, $size{$_}, $_);
}

 
'[tt]stat[/tt]' returns a list, the fifth element of which is the user id.
'[tt]readlink[/tt]' returns the filename pointed to by a symbolic link.
all i can think of for disk usage would be either add up the numbers in the program, or make a system call to 'du'. &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top