Re: Blocks verses Bytes,Mbytes etc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Harry Putnam <hgp@xxxxxxxxxxxxx> writes:

> Harry Putnam <hgp@xxxxxxxxxxxxx> writes:
>
>>   my $line = $_;
>
> Ooops.  my $line should'nt have made it into the final version.  Its
> useless and does nothing

I'm sorry folks... fortunately for me probably no one will try to use
the script I posted... but on the off chance they do, I should at
least post something that works.  Maybe I need some coffee..

#!/usr/bin/perl -w

# Keywords: fdiskcnv - designed to convert fdisk -l output to approx.
# MB equivalents. Script Runs `fdisk -l' inside perl and converts
# the block values to Mbyte values in a second printout.
# Apr 29 2003 2
# &&

$cmd = 'fdisk -l';
open(FDISKL,"$cmd |");
while(<FDISKL>){
  print;
  chomp;
  if(/^\/dev\//){
    $readem = "TRUE";
  }
  if(!/^\/dev\//){
    $readem = '';
  }

  if ($readem &&  /\s+\*\s+/){
  ## if we see the asterisk grab field5
  ## and get rid of any + signs by making + a split field
    ($fld0,$fld4) = (split(/\s+|\+/))[0,4];
    $var = sprintf "%-12s %s %.2f\n","$fld0 " , "MB" , ($fld4 / 1024);
    push @MB_ar, "$var";
  }elsif($readem && $_ !~ /\*/){
    ($fld0, $fld3) = (split(/\s+|\+/))[0,3];
    $var = sprintf "%-12s %s %.2f\n","$fld0 ", "MB" , ($fld3 / 1024);
    push @MB_ar, "$var";
  }
}
close(FDISKL);
print "\n== Approximate Mbyte equivalents ====\n\n";
for(@MB_ar){
  print;
}





[Index of Archives]     [Fedora Users]     [Centos Users]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat Phoebe Beta]     [Yosemite Forum]     [Fedora Discussion]     [Gimp]     [Stuff]     [Yosemite News]

  Powered by Linux