Dear Monks :-), I have two questions related to the following one-liner:
find /opt/splunk/syslog/ -iname "*log*" -type f -mtime +30 | perl -wne
+ 'BEGIN { $sum = 0 }; chomp; $sum += (stat)[7]; END { print "$sum\n"
+}'
1) How should I quote it (escape the single quotes) when I want to execute it on a remote machine via SSH? Ex. ssh root@HOST 'ONE-LINER'
2) Is there is a (smart) way to incorporate the following subroutine into the one-liner?
sub scaleIt {
my $size_in_bytes = shift;
return unless defined $size_in_bytes;
my ( $size, $n ) = ( $size_in_bytes, 0 );
++$n and $size /= 1024 until $size < 1024;
return sprintf "%.0f%s", $size, (qw[ B KB MB GB TB ])[$n];
}
You can talk and talk and have great ideas, but if you don't have a way of sharing those ideas then you are just saying it in you own bubble. -- Tom Limoncelli