On Sat, Jun 19, 2004 at 01:55:02PM -0500, Max Kipness wrote: > But what I would like to do is automatically get the size of the last > created hard linked directory daily through a script.
Try the attached perl script. It counts the blocks in the arguments you specify (like du does), but it leaves out any files that have more links than the number of instances we find in our scan (i.e. if we find "foo" with a link count of 2 and we run across it again in our scan, we count its blocks; if it had a link count of 3 or more and we only ran across it twice, we'd skip it). ..wayne..
#!/usr/bin/perl -w use strict; my %hash; # Keep track of multi-linked inodes my $total_blocks = 0; my @todo = @ARGV; push(@todo, '.') unless @todo; foreach my $fn (@todo) { my($inode,$nlinks,$blocks) = (lstat($fn))[1,3,12]; if (-d _) { opendir(DP, $fn) or die $!; push(@todo, map("$fn/$_", grep(!/^\.\.?$/, readdir(DP)))); closedir DP; } elsif ($nlinks > 1) { if (!defined($hash{$inode})) { $hash{$inode} = $nlinks - 1; next; } next if --$hash{$inode}; } $total_blocks += $blocks; } print "$total_blocks blocks\n"; print int($total_blocks / 2 + .5), "K\n"; # Assumes 512-byte blocks
-- To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html