in="cat"
[ -z "$@" ] || in="echo $@"
- $in | perl -pe 'BEGIN{
+ #use Number::Bytes::Human qw/&format_bytes/;
+ #s/$exp/bytes2h($1)/ge;
+ $in | perl -pe '
+BEGIN{
use NB::Functions qw/&bytes2h/;
$exp = "([\\d\\.]+)";
if (@ARGV and $ARGV[0] =~ /regex=(\S+)/) {
$exp = $1;
}
};
-s/$exp/bytes2h($1)/ge;
+0 and s/$exp/format_bytes($1)/ge
' $args
}
if ($o >= 1099511627776) { return(sprintf('%.2fT',($o/1099511627776))); } # T
elsif ($o >= 1073741824) { return(sprintf('%.2fG',($o/1073741824))); } # G
+ elsif ($o >= 1048576) { return(sprintf('%.1fM',($o/1048576))); } # M
elsif ($o >= 1048576) { return(POSIX::ceil($o/1048576)."M"); } # M
elsif ($o >= 1024) { return(POSIX::ceil($o/1024)."K"); } # K
- else { return $o."bytes"; }
+# NB 02.09.16 else { return $o."bytes"; }
+ else { return $o; }
}
# NB 15.07.07
#------------------------------------------------------------------------------
# Bug if delete - NB 24.02.12 my $opt = shift @_;
-my $opt = \%{$_[0]};
+my $opt = \%{$_[0]}; shift;
my $iziopt;
-my @dbi = @NB::Globals::DBI;
+my @dbi = @_;
require 'DBI.pm' unless $INC{'DBI.pm'};