The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 09-01-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Post

Here's some pseudocode (perl style) to help get you started:

Code:
my %data;
open(LS,"find /tmp -type f -ls | awk '{ print %1,$5,$8,$9,$10 }' |") || die "cannont run find $!";
while (<LS>) {
  if (/(\d+) (\w+) (.+)/) {
    $size=$1;
    $user=$2;
    $date=$3;
    $data{$user}{"size"}+=$size;
    if (is_later_than($data{$user}{"date"},$date)) {
      $data{$user}{"date"}=$date;
    }
  }
}
foreach $user(sort(keys %data)) {
  print "$user used $data{$user}{"size"}, last accessed $data{$user}{"date"}\n";
}

Note that this is a mix of perl and pseudocode, you'll need to fill in the blanks before it will actually run.