hi friends.
i have to make a perl script to generate all users and space(how much they are using) and files(how much files they have) and time(how much time that accessed /tmp buffer) from /tmp directory.
please provide me guidance.
regards
pranesh b. mishra
What have you done so far? Where are you stuck?
Here's some pseudocode (perl style) to help get you started:
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.